package main
import (
"fmt"
)
func main() {
c1 := make(chan interface{})
c2 := make(chan interface{})
close(c1)
close(c2)
c1Count := 0
c2Count := 0
for i := 1000; i > 0; i-- {
select {
case <-c1:
c1Count++
case <-c2:
c2Count++
}
}
fmt.Printf("c1Count:%d\nc2Count:%d\n", c1Count, c2Count)
}
程序输出如下,