Java – Thread dump
Posted by cornel | Filed under Java
I found a very usefully tool especially for Java developers working on Windows. It is called StackTrace and it has several features which allows you to inspect and debug the JVM. The most interesting one for me is the ability to execute a thread dump. In Unix one can obtain that with SIGQUIT but I was previously unable to do that in Windows.
Why would someone need this? Sometimes your application does not respond to any commands (mostly because of deadlocks or some threads are waiting for I/O operations); in order to properly identify what is the cause you can create a thread dump and take a look on thread call stacks.
With StackTrace I found that is very easy to generate the thread dump – install Java Web Start if you do not have it and run the application. Enter the PID of the Java process (you can find it on task manager) and click on thread dump.
It also has a BeanShell console with additional commands.
June 27th, 2008 at 10:56 am
You can also obtain a thread dump as of Java 5 by using the jstack utility, as long as you have the full JDK installed. From the command line type:
jstack
Full documentation is available from Sun’s website here:
http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstack.html