In Java, how do you determine if a thread is running?

Thread.isAlive()


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.


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