合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
``` //生产者 func productor(out chan <- int) { for i:=0; i<10; i++ { fmt.Println("生产:", i*i) out <- i*i } close(out) } //消费者 func consumer(in <- chan int) { for num:=range in{ fmt.Println("消费者:", num) time.Sleep(time.Second) } } func main() { ch := make(chan int, 5) go productor(ch) consumer(ch) } ```