File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

stopping and starting

 
Paul Keohan
Ranch Hand
Posts: 411
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Yuri Gadow
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic