package main import ( _"os" "fmt" "time" )
func main() { for i:=0; i<50; i++ { c := make(chan int) go func( index int,cp chan int ) {// //for { fmt.Println("before send to chan,index is ",index) cp<-0 // will block fmt.Println("after send,index) //} }(i,c)//
go func(cp chan int ){ time.Sleep(5*time.Second) <-cp }(c) } time.Sleep(10*time.Second) //select{}
}
原文链接:https://www.f2er.com/go/190956.html