Topic: 关于Thread的问题 |
Print this page |
1.关于Thread的问题 | Copy to clipboard |
Posted by: xren Posted on: 2002-12-13 12:47 当程序从run method 退出后是不是就等于那个thread 已经死了? 当 一个 thread 已经死了,可不可以再用start method 从新开始那个 thread ? 谢谢 |
2.about thread [Re: xren] | Copy to clipboard |
Posted by: snowbug Posted on: 2002-12-13 13:05 The thread is dead after finish the execution of the run() method. Thread can only start once. So you can not call start() again to reuse it. |
3.Re:关于Thread的问题 [Re: xren] | Copy to clipboard |
Posted by: floater Posted on: 2002-12-13 13:30 Theoritically, you can start that piece of code again, but that particular thread is out of the scope in *runtime* since it's dead. In java, when you fire off the run() in a thread, after that it's done. But you run always get a new thread with the same piece of code and start run(). |
4.use Runnable [Re: xren] | Copy to clipboard |
Posted by: cameo Posted on: 2002-12-15 06:10 you can use Runnable interface to continue a dead thread. |
5.关于Thread的问题 [Re: xren] | Copy to clipboard |
Posted by: xren Posted on: 2002-12-15 16:05 我试了用Runnable interface 也不能 restart a thread 如果直接调用run的话,也不从新开始一个新的 thread. 如果一个thread 已经死了,就不能在调用start()开始一个新的thread. 不知道这个结论是不是对了 谢谢各位帮忙 |
6.Yes! [Re: xren] | Copy to clipboard |
Posted by: 烂泥 Posted on: 2002-12-15 22:09 失掉的是肉体(Thread) l灵魂不会消失(Runable) 要想重生,就只能投胎再来(new) |
7.Re:use Runnable [Re: cameo] | Copy to clipboard |
Posted by: snowbug Posted on: 2002-12-16 23:25 cameo wrote: I don't think you can restart a dead thread. According to the language specification, a dead thread is dead and you simply can not restart it. However, like javaduke said, you can create a new thread use the same runnable object: new Thread((Runnable)deadThread).start(); But make sure you've reset all the fields that might affects the execution of the thread. |
8.Re:关于Thread的问题 [Re: xren] | Copy to clipboard |
Posted by: taogang Posted on: 2002-12-17 13:02 It's impossible to reuse a dead thread, however, it's possible to make a dead thread looks like been reused, your goal is the most important thing. |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |