aspose file tools*
The moose likes Threads and Synchronization and the fly likes stopping and starting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "stopping and starting" Watch "stopping and starting" New topic
Author

stopping and starting

Paul Keohan
Ranch Hand

Joined: Mar 15, 2000
Posts: 411
If you instantiate a Thread is it possible to keep interrupting and starting it with no consequences? I want to be able to re-start the run() method numerous times.
Thanks.
Paul
Martin webster
Greenhorn

Joined: Jun 20, 2001
Posts: 20
From what I understand.. Once a thread is dead it is dead. You can't bring it back into the world of the living. You would have to create a new instance of the thread.


Martin
Yuri Gadow
Greenhorn

Joined: May 08, 2001
Posts: 28
Once a run method is complete, the thread cannot be restarted, period. However, you can change the approach a bit to achieve the same effect. One (of many) ways is to have your run loop on a condition, wait on a shared monitor upon completion, and then use a notify to "restart" it - think work queue. I have some source I can post this evening if it would be helpful.
 
 
subject: stopping and starting