Java thread dump is a stack traces of all active threads in a Java Application. Which gives the information or state of all Java Threads which are live/active in a running Application of Java and their states.
The following are the steps of collecting Java thread dumps in Linux(Unix)
Find the process id of the Java application for which you want to collect thread dump, by using any of the following commands
jps This is a inbuilt tool which comes with Java(JDK tools) useful to find the process id's of the java application
ps -eaf | grep java
"This 'ps' command comes with Unix or Linux itself"
Using kill -QUIT or kill -3 as shown below.
kill -QUIT or kill -3 will produce the following output of stdout console of Java
Using Java in built tools
jconsole,jmc and jvisualvm are the GUI based tools. Taking java thread dumps is a difficult tasks to use UI tools while we are using Unix or Linux boxes
In this "how to" lets use the jstack to collect thread dumps fron Linux or Unix
Output of jstack will be printed in the terminal which we used, we can direct the output of jstack to any file by using the redirect command
jstack java_application.pid >> thread dumps.txt
Related how to'sHow to Analyze Java thread dumps