concurrency - Golang channel 选择语句

标签 concurrency go channels

最近刚在尝试 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/

相关文章:

iOS GCD Max 并发操作

concurrency - 在 Golang 中同时读取多个 channel

go - 即使关闭, channel 也不会消亡

java - 使用数据报 channel 时无法访问端口

Java:与 HikariDataSource 对象的并发

cocoa - 如何将 NSProgressIndicator 绑定(bind)到 NSOperation 的属性?

sql-server - 如何使用Golang SDK查询RDS的任何表格

docker - 以编程方式检查 Docker 容器进程是否以非零状态结束

c++ - 使用互斥锁作为信号量?

c# - 将指针传递给 Go DLL Syscall 中的指针