func main() {
bools := make(chan bool, 3)
chanstrings := make(chan string, 1)
for i := 0; i < 100; i++ {
bools <- true
go func(i int) {
time.Sleep(2 * time.Second)
log.Println(time.Now(), i)
<-bools
}(i)
if i == 99 {
chanstrings <- ""
}
}
<-chanstrings
}
网友评论