Tuesday, 26 August 2014

How to take thread dump from JVM

Step 1: Get the Process id of your java program. JDK ships 'jps' command which list all java process ids.

public class GetDump {
    public static void main(String args[]) throws InterruptedException{
        Thread.sleep(20000);
    }
}

Run the above program and run the jps command to get the PID of this program.

Example
C:\>jps -l
7632 GetDump
1048 sun.tools.jps.Jps
2620

Step 2: use jstack command to obtain thread dump.
jstack pid

Where pid stands for process id.

Example
C:\>jstack -l 7632

Where 7632 is the PID of GetDump program.


Output




                                                             Home

No comments:

Post a Comment