最近刚在尝试 go。我想知道如果您有一个 select 语句等待几个 channel 上的通信,并且如果两个或多个 channel 同时收到一条消息,会发生什么情况。如果所有消息同时到达,select 将如何确定接受哪个 channel ?
谢谢!
最佳答案
来自 the spec :
If multiple cases can proceed, a uniform pseudo-random choice is made to decide which single communication will execute.
所以选择是不确定的。
关于concurrency - Golang channel 选择语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19865194/