| Author |
Verifying if a thread is alive
|
David Duran
Ranch Hand
Joined: Feb 11, 2002
Posts: 122
|
|
I have a program that starts several new threads, all of which loop infinitely, each taking time to sleep between execution of it's own code. My question is this- If I name the threads from my main "hub" (the program which starts all the threads), is there a way for me to use the Thread name to verify whether or not that that thread is still running after x amount of time?
|
 |
Marlene Miller
Ranch Hand
Joined: Mar 05, 2003
Posts: 1391
|
|
Would the Thread methods getName() and isAlive() serve your purpose? [ June 24, 2003: Message edited by: Marlene Miller ]
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
|
Your "hub" thread could just store an ArrayList or something containing references to the threads it has created. Then later you can loop through the list and check isAlive() on each one. I don't think you need the name for this, but maybe you will want to assign meaningful names for readability or something.
|
"I'm not back." - Bill Harding, Twister
|
 |
 |
|
|
subject: Verifying if a thread is alive
|
|
|