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()

}
posted @ 2020-06-12 13:58  brady-wang  阅读(240)  评论(0编辑  收藏  举报