Created
November 22, 2023 12:09
-
-
Save yumed15/650ac349c1949d81d07b8ba605ae2700 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
var wg sync.WaitGroup | |
sayHello := func() { | |
defer wg.Done() // <- before we exit the goroutine, we indicate | |
// to the WaitGroup that we have exited | |
fmt.Println("hello") | |
} | |
wg.add(1) // <- one goroutine is starting | |
go sayHello() | |
wg.Wait() // <---- join point |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment