views:

1366

answers:

5

How do you determine if a thread is running?

+8  A: 

Thread.isAlive()

Wayne
A: 

Check the thread status by calling Thread.isAlive

+2  A: 

I think you can use GetState(); It can return the exact state of a thread.

Chathuranga Chandrasekara
+5  A: 

You can use this method:

boolean isAlive()

It returns true if the thread is still alive and false if the Thread is dead. This is not static. You need a reference to the object of the Thread class.

One more tip: If you're checking it's status to make the main thread wait while the new thread is still running, you may use join() method. It is more handy.

CodingTales
+1  A: 

Have your thread notify some other thread when it’s finished. This way you’ll always know exactly what’s going on.

Bombe