- 并发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()
文档更新时间: 2024-10-21 01:07 作者:Yoby