Created
March 7, 2022 00:15
-
-
Save armando-couto/c1823a709e163934be2a35117e65a01d to your computer and use it in GitHub Desktop.
The first question of multiple channels being ready simultaneously seems interesting. Let’s just try it and see what happens!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
c1 := make(chan interface{}) | |
close(c1) | |
c2 := make(chan interface{}) | |
close(c2) | |
var c1Count, c2Count int | |
for i := 1000; i >= 0; i-- { | |
select { | |
case <-c1: | |
c1Count++ | |
case <-c2: | |
c2Count++ | |
} | |
} | |
fmt.Printf("c1Count: %d\nc2Count: %d\n", c1Count, c2Count) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment