Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to know thread is running from another class?  RSS feed

 
sridhar mam
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am creating a thread, when my webapp is started. I want to periodically check, whether this thread is running or not. If not, I want to create a new thread.

To create a new thread, I have used a servlet class constructor. When webapp is deployed, this code is starting the thread. But, on the webapp access, I want to check whether this thread is running or not.

Please help me out.

Thanks in advance!

Sri


 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Thread class has a isAlive() method.

Register your thread somewhere so you can globally access it's instance and then check.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!