Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
9 lines (6 sloc) 667 Bytes



假如我们执行sync.Add()的次数大于执行sync.Done()的次数,这种情况下,通过在第一个fmt.Printf(“%#v \ n”,waitGroup)之前添加waitGroup.Add(1)语句,然后执行go run的输出如下:

$ go run syncGo.go Going to create 20 goroutines. sync.WaitGroup{noCopy:sync.noCopy{}, state1:[12]uint8{0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, sema:0x0} sync.WaitGroup{noCopy:sync.noCopy{}, ...
You can’t perform that action at this time.