Golang中的通道队列有多大?

huangapple go评论79阅读模式
英文:

How big is the channel queue in Golang?

问题

在Golang中,无缓冲通道就是一个先进先出(FIFO)队列。这个队列中可以同时存在多少个项目?是否有限制?

英文:

In Golang unbuffered channel is just a FIFO queue. How many items can be in that queue at any time? Is there a limit?

答案1

得分: 4

通道本身可以容纳的项目数量为零,因为它是无缓冲的。但是等待在通道上发送的goroutine数量没有限制。(当一个goroutine尝试在没有缓冲区或满缓冲区的通道上发送时,它会阻塞,直到另一个goroutine准备好从通道接收。)

英文:

The number of items that can be in the channel itself is zero, because it is unbuffered. But there is no limit on the number of goroutines than can be waiting to send on the channel. (When a goroutine tries to send on a channel with no buffer or a full buffer, it blocks until another goroutine is ready to receive from the channel.)

huangapple
  • 本文由 发表于 2017年1月3日 02:11:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/41431467.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定