go sync.WaitGroup

package main

import (
"fmt"
"sync"
)

func say(i int ,wg *sync.WaitGroup) {
defer wg.Done()
fmt.Println(i)
}

func main() {
var wg sync.WaitGroup
for i:=0;i<1000;i++{
wg.Add(1)
go say(i,&wg)
}
fmt.Println(4444444)
wg.Wait()

}
上一篇:golang开发:CSP-WaitGroup Mutex


下一篇:golang 协程学习