golang并发

panyuan · · 3752 次点击
polaris
社区,需要你我一同完善!
简单的写了一个: package main import("time") func main() { go Write() go Read() select {} } var buffer chan int = make(chan int, 10) func Write() { i := 0 for { buffer <- i time.Sleep(500e6) i++ } } func Read() { for { i := <-buffer println(i) } }
#1
更多评论