Thread dump
jstack: Java comes with jstack tool through which we can generate thread dump for a java process.This is a two step process.
Thread Priority: Priority of the thread
Thread ID: Represents the unique ID of the Thread
Thread Status: Provides the current thread state, for example RUNNABLE, WAITING, BLOCKED. While analyzing deadlock look for the blocked threads and resources on which they are trying to acquire lock.
Thread callstack: Provides the vital stack information for the thread. This is the place where we can see the locks obtained by Thread and if it’s waiting for any lock.
Find out the PID of the java process using
Run jstack tool as jstack PID to generate the thread dump output to console, you can append thread dump output to file using command
This is slightly different from other ways to generate thread dump.
When kill command is issued, thread dump is generated to the System out of the program.
So if it’s a java program with console as system out, the thread dump will get printed on the console.
If the java program is a Tomcat server with system out as catalina.out, then thread dump will be generated in the file.
Java 8 has introduced jcmd utility. You should use this instead of jstack if you are on Java 8 or higher. Command to generate thread dump using jcmd is
ps -eaf | grep java
commandRun jstack tool as jstack PID to generate the thread dump output to console, you can append thread dump output to file using command
“jstack PID >> mydumps.tdump“
We can usekill -3 PID
command to generate the thread dump.This is slightly different from other ways to generate thread dump.
When kill command is issued, thread dump is generated to the System out of the program.
So if it’s a java program with console as system out, the thread dump will get printed on the console.
If the java program is a Tomcat server with system out as catalina.out, then thread dump will be generated in the file.
Java 8 has introduced jcmd utility. You should use this instead of jstack if you are on Java 8 or higher. Command to generate thread dump using jcmd is
jcmd PID Thread.print
Thread detais
Thread Name: Name of the ThreadThread Priority: Priority of the thread
Thread ID: Represents the unique ID of the Thread
Thread Status: Provides the current thread state, for example RUNNABLE, WAITING, BLOCKED. While analyzing deadlock look for the blocked threads and resources on which they are trying to acquire lock.
Thread callstack: Provides the vital stack information for the thread. This is the place where we can see the locks obtained by Thread and if it’s waiting for any lock.
Comments
Post a Comment