package main
import (
_ "a1/utils"
"fmt"
_ "time"
)
func writeData(initChan chan int) {
for i := 1; i <= 50; i++ {
initChan <- i
fmt.Printf("writeData=%v\n", i)
}
close(initChan)
}
func readData(initChan chan int, exitChan chan bool) {
for {
v, ok := <-initChan
if !ok {
break
}
fmt.Printf("readData=%v\n", v)
}
exitChan <- true
close(exitChan)
}
func main() {
intChan := make(chan int, 50)
exitChan := make(chan bool, 1)
go writeData(intChan)
go readData(intChan, exitChan)
for{
_,ok := <-exitChan
if !ok{
break
}
}
}