作者TonyQ (骨头)
站内java
标题Re: [问题] thread问题
时间Sun Aug 20 18:24:24 2006
※ 引述《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