package main import ( "fmt" "sync" ) func hello(num ...int) { num[0] = 18 } func main() { closeChan := make(chan struct{}) wg := &sync.WaitGroup{} for i := 0; i < 10; i++ { wg.Add(1) go func(i int) { defer func() { wg.Done() }() <-closeChan fmt.Println(i, "closed") }(i) } close(closeChan) //广播关闭 wg.Wait() }
标签:wg,int,chan,sync,广播,func,go From: https://www.cnblogs.com/a-flydog/p/17143388.html