The go language execution waits until the background goroutine execution completes the instance analysis
- 2020-05-26 09:20:12
- OfStack
This article illustrates the use of the go language to wait until the goroutine execution is complete. Share with you for your reference. The details are as follows:
var w sync.WaitGroup
w.Add(2)
go func() {
// do something
w.Done()
}
go func() {
// do something
w.Done()
}
w.Wait()
I hope this article has been helpful to your programming of Go language.