How will you take thread dump in Java? How will you analyze Thread dump | Eklavya Online

How will you take thread dump in Java? How will you analyze Thread dump

A Thread Dump is a complete list of active threads. A java thread dump is a way of finding out what each thread in the JVM is doing at a particular point of time. This is especially useful when your java application seems to have some performance issues. Thread dump will help you to find out which thread is causing this. There are several ways to take thread dumps from a JVM. It is highly recommended to take more than 1 thread dump and analyze the results based on it. Follow below steps to take thread dump of a java process

  • Step 1

On UNIX, Linux and Mac OSX Environment run below command:

ps -el | grep java

On Windows:

Press Ctrl+Shift+Esc to open the task manager and find the PID of the java

process

  • Step 2:

Use jstack command to print the Java stack traces for a given Java process PID

jstack [PID]