第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

繼續(xù)默認(rèn)為什么其他案例沒有被打印出來

繼續(xù)默認(rèn)為什么其他案例沒有被打印出來

Go
繁星點(diǎn)點(diǎn)滴滴 2022-08-24 10:57:53
當(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”)    }}
查看完整描述

1 回答

?
qq_笑_17

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超7個(gè)贊

func main() {

    output1 := make(chan string)

    output2 := make(chan string)

    go server1(output1)

    go server2(output2)

    for {

        select {

        case s1 := <-output1:

            fmt.Println(s1)

        case s2 := <-output2:

            fmt.Println(s2)

        default: // todo: return

            fmt.Println("X")

        }

    }

}


查看完整回答
反對(duì) 回復(fù) 2022-08-24
  • 1 回答
  • 0 關(guān)注
  • 70 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)