Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Golang channels select statement

Just experimenting with go recently. I was wondering what will happen if you have a select statement waiting for communication on a few channels and if a message comes AT THE SAME time on two or more channels. How will the select determine which channel to accept if all the messages come at the same time?

Thanks!

like image 851
Feras Avatar asked Nov 08 '13 17:11

Feras


1 Answers

From the spec:

If multiple cases can proceed, a uniform pseudo-random choice is made to decide which single communication will execute.

So the choice is non-deterministic.

like image 166
nemo Avatar answered Sep 25 '22 00:09

nemo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!