Re: How to restart a thread in Java
- From: "Karl Uppiano" <karl.uppiano@xxxxxxxxxxx>
- Date: Sat, 28 Oct 2006 02:44:11 GMT
Does legal mean the code won't compile or that it just isn't good
practice? I ask because I have a class that contains a run() for a thread
and I call it everytime I need to do the operation that the run() performs
and I do so w/o creating a new instant of the class that the run() is a
part of. So far I haven't seen any problems with that approach. Is that
not the same thing as what the original poster was trying to do?
Legal in the sense that it won't work. If you create a new thread and start
it, when it finishes running whatever top level run() method you give it,
and that run() method returns, that thread is finished and it will not
restart, no matter what you do. You will have to create a new one. You can
create new threads all day long, and give them the same old run() method the
same old instance, that works just fine. But the thread dies when run()
returns, and it cannot be revived.
.
- References:
- How to restart a thread in Java
- From: vanisathish
- Re: How to restart a thread in Java
- From: Christopher Benson-Manica
- Re: How to restart a thread in Java
- From: Brandon McCombs
- How to restart a thread in Java
- Prev by Date: Re: javax.imageIO error...
- Next by Date: Re: importing using the wildman with javac
- Previous by thread: Re: How to restart a thread in Java
- Next by thread: Re: How to restart a thread in Java
- Index(es):
Relevant Pages
|