I searched and found ways to determine if another thread is suspended by adding a boolean to it. But, I do not want (prefer not) to modify that other thread's code. And, I need to detect if it is frozen by any reason (even a bug, so in this case that other thread may also be unresponsive).
I see how eclipse does it and shows the application's thread is not responding, I wonder how they coded that.
Motivation: I need this to release the mouse (ungrab it) from a 3D lwjgl application, and this must be independent of any IDE, the application itself must do it. I am trying to monitor the main application thread.
While not necessarily the best idea, you can use
Thread#getState()
to view the current state of the thread.However, this will depend on the context of the thread. If it is frozen because it cannot break out of a loop, then this method cannot work. Additionally, if it is simply waiting on a lock or on a bounded collection, it will be a false call.
The thread should in these 3 states:
BLOCKED
,WAITING
, orTIMED_WAITING
.