testllgo: waitgroup

This commit is contained in:
xushiwei
2024-06-18 10:17:05 +08:00
parent e7de841939
commit a3197c12a8
2 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
package main
import (
"sync"
)
func main() {
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()
println("work 1")
}()
go func() {
defer wg.Done()
println("work 2")
}()
wg.Wait()
println("done")
}

View File

@@ -0,0 +1 @@
;