Skip to content

Instantly share code, notes, and snippets.

@EvilFreelancer
Created May 12, 2023 15:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvilFreelancer/9c66db1f39a8ac8d363f6327fff1adb9 to your computer and use it in GitHub Desktop.
Save EvilFreelancer/9c66db1f39a8ac8d363f6327fff1adb9 to your computer and use it in GitHub Desktop.
Горутины в GoLang
package main
import (
"fmt"
"time"
)
func printString(text string) {
for i := 0; i < 3; i++ {
time.Sleep(100 * time.Millisecond)
fmt.Println(text)
}
}
func main() {
go printString("Привет")
go printString("Мир")
// Ожидаем завершения горутин
time.Sleep(1 * time.Second)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment