你能解释一下下面的错误吗:fatal error:
true
true
all goroutines are sleep - deadlock!
package main
import (
"fmt"
)
func printer(ch chan bool) {
ch <- true
}
func main() {
var c chan bool = make(chan bool, 2)
for i := 0; i < 5; i++ {
go printer(c)
}
for i := range c {
fmt.Println(i)
}
}
jeck猫
相关分类