- 并发conc github.com/sourcegraph/conc
原声写法var wg conc.WaitGroup defer wg.Wait() startTheThing(&wg) func startTheThing(wg *conc.WaitGroup) { wg.Go(func() { fmt.Println(1) }) }
conc写法var wg sync.WaitGroup for i := 0; i < 10; i++ { wg.Add(1) go func() { defer wg.Done() doSomething() }() } wg.Wait()
var wg conc.WaitGroup for i := 0; i < 10; i++ { wg.Go(doSomething) } wg.Wait()
作者:Yoby 创建时间:2024-05-27 01:16
更新时间:2024-12-05 13:26
更新时间:2024-12-05 13:26