We have a junit test runner which timeout if one test is hanging. Now I want create a thread dump via API.
I know I can request the stacktraces via Thread.getAllStackTraces(). But the thread dump on the console include many more information like the monitor which a thread is waiting.
Are there an API to request the monitor on which a thread is waiting?
You could use JMX to create a thread dump.
See How do I create a thread dump via JMX? for an example. The ThreadInfo class supports getting the locked monitors.