問題描述兩個(gè)goroutine,一個(gè)goroutine中做鍵盤的輸入,另一個(gè)goroutine做其它數(shù)據(jù)處理。運(yùn)行后,如果我不輸入數(shù)據(jù),另一個(gè)goroutine也停止運(yùn)行了。也沒調(diào)度。我希望即使我不輸入數(shù)據(jù),也不要影響另一個(gè)goroutine。問題出現(xiàn)的環(huán)境背景及自己嘗試過哪些方法相關(guān)代碼//請(qǐng)把代碼文本粘貼到下方(請(qǐng)勿用圖片代替代碼)packagemainimport("fmt""os""bufio""math/rand")funcmain(){msgChan:=make(chanstring)roundChan:=make(chanint)sleepChan:=make(chanbool)goinput(msgChan)goroundNum(roundChan)goScheduler(msgChan,roundChan)
萌新求教!go語言bufio.NewReader(os.Stdin) 阻塞了goroutine調(diào)度,怎么解決?
慕斯王
2019-07-27 00:48:20