Golang为什么设计channel(管道)?

236 阅读1分钟

Golang 管道能干什么

  1. 数据共享
  2. 生产者,消费者模式
  3. 控制并发

为什么Golang设计管道?

Don’t communicate by sharing memory, share memory by communicating. 这是 Rob Pike 在 2015 年的一次 Gopher 会议中提到的一句话,虽然有一点绕,但也指出了使用 Go 语言的哲学,我尝试着来翻译一下:“执行业务处理的 goroutine 不要通过共享内存的方式通信,而是要通过 Channel 通信的方式分享数据。” 作者:普通熊猫 链接:www.zhihu.com/question/44…

其他语言的“管道”是什么?

  1. java blocking queue
  2. python run on event loop