Skip to content

Instantly share code, notes, and snippets.

@yumed15
Created November 22, 2023 12:24
Show Gist options
  • Save yumed15/83f9b0823e3d02f3638636f356588a23 to your computer and use it in GitHub Desktop.
Save yumed15/83f9b0823e3d02f3638636f356588a23 to your computer and use it in GitHub Desktop.
begin := make(chan interface{})
var wg sync.WaitGroup
for i:=0; i<5; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
<- begin
fmt.Printf("%v has begun\n", i)
}()
}
fmt.Println("unblocking goroutines...")
close(begin)
wg.Wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment