A thread dump is a snapshot of the state of all threads that are part of the process. The state of each thread is presented with a so called stack trace, which shows the contents of a thread’s stack. Some of the threads belong to the Java application you are running, while others are JVM internal threads.
A thread dump reveals information about an application’s thread activity that can help you diagnose problems and better optimize application and JVM performance; for example, thread dumps automatically show the occurrence of a deadlock. Deadlocks bring some or all of an application to a complete halt. It also shows the memory details at a point it was taken, a very very useful thing in analysing problems.
Taking thread dump.
- On Linux or Unix you can -> kill -3 JAVA_PID , This will print the thread dump in the JVMs standard out file, for example in case of Weblogic look into .out log file
- You can take thread dump from within Weblogic Console,
Login to weblogic console, go to servers>Server_Name> Monitoring > Threads
Here you will find “Dump Thread Stacks” button, click on that and you will see thethread dump in the console itself.
3. Redirecting thread dump in any other file, use jstack which comes with JDK.
jstack -l JAVA_PID > jstack.out
4. Taking Thread Dump using jvisualvm
You can take live thread dump using jvisualvm, a great free monitoring tools which gets shipped with JDK.