package main
import (
"fmt"
"time"
)
func main() {
ch := make(chan int, 64)
go producer(1, ch)
go producer(5, ch)
go consumer(ch)
time.Sleep(time.Second * 5)
}
// 生产者
func producer(factor int, out chan int) {
for i := 0; ; i++ {
out <- i * factor
}
}
// 消费者
func consumer(in chan int) {
for v := range in {
fmt.Println(v)
}
}