英文:
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.)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论