Created
November 22, 2023 12:24
-
-
Save yumed15/83f9b0823e3d02f3638636f356588a23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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