Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created November 8, 2022 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/b1bd8ffb42e86a676ceee87d59bef69d to your computer and use it in GitHub Desktop.
Save BetterProgramming/b1bd8ffb42e86a676ceee87d59bef69d to your computer and use it in GitHub Desktop.
func main() {
runtime.GOMAXPROCS(2)
var wg sync.WaitGroup
wg.Add(2)
fmt.Printf("Starting")
go func() {
defer wg.Done()
for n := 0; n < 10; n++ {
fmt.Printf("%d\n", n)
}
}()
go func() {
defer wg.Done()
for n := 100; n < 200; n++ {
fmt.Printf("%d\n", n)
}
}()
fmt.Println("Waiting...")
wg.Wait()
fmt.Println("Finish!")
}​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment