A thread dump is a list of all the Java threads that are currently active in a Java Virtual Machine (JVM).
There are several ways to take thread dumps from a JVM. It is highly recommended to take more than 1 thread dump. A good practice is to take 10 thread dumps at a regular interval (for example, one thread dump every ten seconds).
The first piece of information you will need to be able to obtain a thread dump is your Java process's PID.
The Java JDK ships with the jps command which lists all Java process ids. You can run this command like this:
jps -l 70660 sun.tools.jps.Jps 70305
Note: In Linux and UNIX, you may have to run this command as sudo -u user jps -l, where "user" is the username of the user that the Java process is running as.
If this doesn't work or you still cannot find your Java process, (path not set, JDK not installed, or older Java version), use
If installed/available, we recommend using the jstack tool. It prints thread dumps to the command line console.
To obtain a thread dump using jstack, run the following command:
jstack -l <pid>
You can output consecutive thread dumps to a file by using the console output redirect/append directive:
jstack -l <pid> >> threaddumps.log
-Xrsjvm parameter is enabled
 Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 22893: Operation not permitted sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 22893: Operation not permitted ... Caused by: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 22893: Operation not permitted ... sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.run(LinuxDebuggerLocal.java:138)
Just run it like this:
sudo -u <user> jstackSeries.sh <pid> <aemserveruser> <count> <delay>
sudo -u aemuser jstackSeries.sh 1234 aemserveruser 10 3
Note: The top output has the native thread id in decimal format while the jstack output has the nid in hexadecimal. You can match the high cpu thread from the top output to the jstack output by converting the thread id to hexadecimal.
In addition to the script above, we also have a similar Windows Powershell script and an Adobe AEM specific script on github.
Thread Dump Tool for Adobe Experience Manager
If you are using Adobe Experience Manager product then you can install this tool to have a simple UI for generating thread dumps.
If the jstack tool is not available to you then you can take thread dumps as follows:
Note: Some tools cannot take thread dumps from the JVM if the commandline parameter
-Xrs is enabled. If you are having trouble taking thread dumps then please see if this option is enabled.
On UNIX, Mac OS X, and Linux, you can send a QUIT signal to the Java process to tell it to output a thread dump to standard output.
jvmoutput.logfile mentioned in step 2.
Get a thread dump from jconsole tool, by using a plugin: 
Here's how you can request a thread dump:
jconsole.exeof JDK 1.6:
jconsole.exe -pluginpath /path/to/file/tda.jar
http://<host>:<port>/system/console/status-Threadsto get a thread list. However, please note that these thread dumps will not work with thread dump analysis tools such as samurai or tda.
All Adobe Products running in a JVM