How to get thread dump in java

Java thread dump is a handy information to figure out how the application is behaving on specific point of time.There are two ways to take the thread dump in a java based application.First we will see how to take a thread dump in Linux/Unix machine Linux/Unix We need to execute the blow command to get the thread dump and please make sure that JDK is installed in the machine.Here pid id the process id which we wanted to take the thread dump.

jstack -F pid > /tmp/ThreadDump.tdump

Windows. In windows its slight different than how we used to do in Linux/Unix but still we are going to use the java tools to get the thread dump. Go to java installation folder click on jvisualvm.exe under bin folder.

thread dump

This way we can get thread dump printed in the console we can copy and paste the information for further analysis.
thread dump 2