How could I get lock object Thread is waiting on?
I have thread dump and I can see one SwingWorker started a confirmation dialog using invokeAndWait() awaiting user interaction.
How could I detect this scenario programmatically?
"Some swing worker -1-thread-8", WAITING, prio=5, tid=128
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at java.awt.EventQueue.invokeAndWait(EventQueue.java:1038)
at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1326)
at ...
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
I posted a similar answer a while back. The trick is to use Management extensions provided by the JDK in case you are interested in the status of all the running threads.