JVisualVM connects to a Java process over JMX and can produce a thread dump through the click of a button. I'd like to add a similar feature to my own application so that it can request thread dumps from remote services.
Which MBeans do I need to interrogate to get this information? and how?
You can use MBean with name "java.lang:type=Threading"
. It's interface is described here.
In order to get thread dump you first need to use getAllThreadIds
method and then loop through all retrieved ids and call getThreadInfo
method for each of them.
You can use the ThreadMXBean management interface.
This FullThreadDump class demonstrates the capability to get a full thread dump and also detect deadlock remotely using JMX.
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