In Java, how will you take thread dump?
Answered
In Java, how will you take thread dump?
Best answer
A thread dump is a list of all the Java threads that are currently active in a Java Virtual Machine (JVM).
It is highly recommended to take more than 1 thread dump. A good practice is to take multiple thread dumps at a regular interval. There are several ways to take thread dumps from a JVM:
- Get the PID of your java process. The first piece of information you will need to be able to obtain a thread dump is your java process’s PID. The JDK ships with the jps command which lists all java process ids.
- Request a Thread Dump from the JVM using jstack option. It prints thread dumps to the command line console. This tool is available as part of JDK since 5.0