We profiled our application with jvisualvm and found out that it spends a lot of time in Object.wait().
How do I find the objects that this method is called for?
In fact, the Java SE SDK comes with a useful class ThreadInfo which you can inspect to learn why a thread is blocked and what it is waiting on, including the full stacktrace to the wait point, and the total time in millis spent waiting.
You use this class via the java.lang.management package and specifically ManagementFactory.getThreadMXBean() You can then use this class to inspect your blocked threads programmatically.
Here is a relevant screenshot from JConsole:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With