go并发学习

loop: break后,跳出selctor,然后跳到loop到最后end。

Loop:
for {
select {
case v, ok := <-intChan:
if !ok {
break Loop
}
ts1 = time.Now().Unix()
if ts0 == 0 {
fmt.Println("Received:", v)
} else {
fmt.Printf("Received: %d [interval: %d s]\n", v, ts1-ts0)
}
}
ts0 = time.Now().Unix()
time.Sleep(receptionInterval)
}
fmt.Println("End.")
}

posted on 2021-04-26 10:12  星星眨着眼  阅读(27)  评论(0编辑  收藏  举报

导航