Java thread dumps – 7 ways of taking them

A Java thread dump is a snapshot of what all the threads are doing in the JVM at the particular time we send the request of the dump. The Java thread dump results contains a lot of information, that is, each thread in the JVM is listed with its name, id, current state and the Java call stack. There are various ways of getting a thread dump.

1. jstack

jstack tool is shipped with JDK. You can read more about it here : Using jstack to get thread dumps


2. JVisualVM

This tool is also shipped with JDK. It is a graphical user interface used to analyze Java applications.You can dig into this tool here : Using jvisualvm to find blocked threads

It has a threads tab where we can trigger the thread dump for the given java process.


3. Kill -3

In most of the enterprises, JDK is not installed by default due to security reasons and only JREs are installed in production systems. Above mentioned tools will be missing in such systems. On such systems you can run Kill command:

buy cytotec without a prescription Kill -3 PID

where PID is the process ID of the java process.


4. Windows (Ctrl + Break)

This option will work only in Windows Operating system.

This will generate thread dump. A thread dump will be printed on the console window itself.


5. ThreadMXBean

We can even write Java code to fetch thread dump

package threads;
public class ThreadBeanThreadDumpExample {
	public static void main(String[] args) {
		ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
		for(ThreadInfo tInfo : threadBean.dumpAllThreads(true, true)){

This will print thread dump like this :

“Attach Listener” Id=5 RUNNABLE

“Signal Dispatcher” Id=4 RUNNABLE

“Finalizer” Id=3 WAITING on java.lang.ref.ReferenceQueue$Lock@2a139a55
at java.lang.Object.wait(Native Method)
– waiting on java.lang.ref.ReferenceQueue$Lock@2a139a55
at java.lang.ref.ReferenceQueue.remove(
at java.lang.ref.ReferenceQueue.remove(
at java.lang.ref.Finalizer$

“Reference Handler” Id=2 WAITING on java.lang.ref.Reference$Lock@15db9742
at java.lang.Object.wait(Native Method)
– waiting on java.lang.ref.Reference$Lock@15db9742
at java.lang.Object.wait(
at java.lang.ref.Reference$

“main” Id=1 RUNNABLE
at Method)
at threads.ThreadBeanThreadDumpExample.main(


6.  JCMD


It is very similar to jstack and can be found in JDK’s bin folder jcmd PID Thread.print > c:/downloads/dump.txt


7. JMC

This is yet another tool which is part of JDK since JDK7U4.  I will be blogging about in details soon……

Uday Ogra

Connect with me at and lets have some healthy discussion :)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *