func main() {
ii := 10
queue := make(chan int, 100)
defer close(queue)
for i := 0; i < 5; i++ {
go worker(i, queue)
}
for {
//k := rand.Intn(1000)
for i := 0; i < 200; i++ {
queue <- ii
}
time.Sleep(1 * time.Second) // 2秒待つ
ii++
go worker(ii, queue)
}
}
func worker(i int, queue chan int) {
for j := range queue {
fmt.Println(i, ",", j)
}
}