當(dāng)我運(yùn)行此代碼時(shí),我不明白為什么在打印X后它不打印其他情況。我希望我應(yīng)該看到X打印出來三秒鐘,然后最后從server2package mainfunc server1(ch chan string) { time.Sleep(6 * time.Second) ch <- "from server1"}func server2(ch chan string) { time.Sleep(3 * time.Second) ch <- "from server2"}func main() { output1 := make(chan string) output2 := make(chan string) go server1(output1) go server2(output2) select { case s1 := <-output1: fmt.Println(s1) case s2 := <-output2: fmt.Println(s2) default: fmt.Println(“X”) }}
繼續(xù)默認(rèn)為什么其他案例沒有被打印出來
繁星點(diǎn)點(diǎn)滴滴
2022-08-24 10:57:53