How to get Thread Dumps from java application and how to analyze them

Thread dmps can say a lot about your application, but without a tool to do analysis on them are useless.
We will focus on how to get thread dmps from jboss application server as example, and how to analyze them.

First thing you need to do is get the processId of your jboss application, we can use something like this:

That will return the process which contains jboss on their data.


Now that you have the processId is just matter of call this jstack command to get the thread dmp



This will create a file called thread_running.out which is the actual thread dmp.

now a single thread dmp is not that useful, so I suggest you get several ones of the application your want to know about.

Once you have a several of them is time to analyze them.

There are several options, online tools, stand alone programs, but there is an eclipse plugin that is very friendly is called lockness, just go to the site and follow the steps to install it.

There is a bad thing, Luna does not support this, I bet that there is a work around for it, but I do not have that, so I used it on Kepler version.

Once Lockenss is installed you can see your thread dmps files in an eclipse window as follows:

Then you can see each thread dmp file inside eclipse, see dependencies between threads, deadlocks, threads waiting and what do started them, this will help you to trouble shoot faster an odd issue about a long running thread or dead locks on your application.






Special Thanks to Lockness plugin for exist.

Comments