The Go statement is selectnot biased against any (prepared) cases. Quoting from the specification:
, , , . , , . , "select" , .
, . , , .
, , Go Playground GOMAXPROCS=1 ( ), goroutine . , goroutines . , (, ), , , .
, goroutines , "" goroutines, (-).
, GOMAXPROCS=4, "" . , :
finish one acount, bcount 1000 901
finish one acount, bcount 1000 335
finish one acount, bcount 1000 872
finish one acount, bcount 427 1000
, : go
select , . , select, , :
for {
select {
case <-chana:
acount++
default:
}
select {
case <-chanb:
bcount++
default:
}
if acount == 1000 || bcount == 1000 {
fmt.Println("finish one acount, bcount", acount, bcount)
break
}
}
2 2 ( ), , , - .
goroutine . :
, Go
Goroutines 8kb windows OS thread 1 mb
, goroutines golang?