Re: [問題] thread問題
※ 引述《YRED (~~~)》之銘言:
: 新手的問題
: 某段聊天程式~
: 有個thread會跑下面的run
: public void run() {
: .......(我省略了一些I/O程式碼~沒貼上來)
: while((message = theInputStream.readLine()) != null) {
: message = "re: " + message + "\n";
: chatBox.update();
: }
: }
: 我想問的是~這個thread即使第一次跑完while迴圈~
: 也就是theInputStream.readLine()讀完了~
: 它之後~還是會三不五時的去檢查theInputStream.readLine()是否有東西
: 然後再跑迴圈?
: 其實我想問~第一次迴圈跑完~不就結束了嗎
: 為何thread之後會知道~還要在check ?
這問題怎麼有頭沒尾的 = =??
基本上 RUN除非有人去執行這個THREAD
不然應該是跑完就結束了...(吧)
如果Thread會知道 再check 應該是有其他的檢查機制 再啟動這個run
這要看程式才會知道 = =
真是大哉問...
--
站內^^
--
String temp="relax"; | Life just like programing
while(buringlife) String.forgot(temp); | to be right or wrong
while(sleeping) brain.setMemoryOut(); | need not to say
stack.push(life.running); | the complier will
stack.push(scouting.buck()); | answer your life
stack.push(bowling.pratice()); | Bone everything
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.138.240.58
討論串 (同標題文章)