How do you determine if a thread is running?
Check the thread status by calling Thread.isAlive
.
Thread.isAlive()
You can use: Thread.currentThread().isAlive();
. Returns true if this thread is alive; false otherwise.
I think you can use GetState(); It can return the exact state of a thread.
To be precise,
Thread.isAlive()
returns true if the thread has been started (may not yet be running) but has not yet completed its run method.
Thread.getState()
returns the exact state of the thread.
Have your thread notify some other thread when it’s finished. This way you’ll always know exactly what’s going on.