Golang|go等待所有线程退出

code

package mainimport ( "fmt" "sync" )func main() { var wg sync.WaitGroupfor i := 0; i < 10; i++ { wg.Add(1) go func(){ fmt.Println("Hello World") wg.Done() }() }wg.Wait() }

    推荐阅读