ThreadDump acquisition and analysis tool, and threaddump acquisition
This section describes how to obtain ThreadDump and the analysis tools of ThreadDump.
1) in the Java program running session, use the following method:
Unix and Linux: CTRL -\
Windows: CTRL-BREAK
2) method 1) it is required that the Java program session be used. If it is not in the Java program session, what should we do?
Use the Jstack tool (jstack pid) provided in Jdk, which is applicable to both Windows and Linux. If you do not want to use this tool or have not installed it, you can also use the following command:
Linux: kill-3 pid
Windows: SendSignal.exe pid
It should be noted that the kill-3 pid is the shellprogram in linux, and sendsignal.exe used in Windows is a tool written by a cool named Louis. In fact, it simulates CTRL-BREAK.
Download the SendSignal.exe tool and the source code.
3) Sometimes, you may not have the process access permission. For example, in Linux, what if multiple users want to obtain ThreadDump?
You can only get it by writing a Java program. You can use JMX as a prompt.
There is a Threading # dumpAllThreads (boolean, boolean) method in the java. lang field. With this method, you can directly obtain the ThreadDump information.
4) if you want to see why your application is eating exceptionally high memory or getting stuck frequently, and so on, if you want to find out the cause, you can also use jconsole, jvisualvm, and jprofile to obtain and analyze ThreadDump and HeapDump. Of course, if you are a Java Developer, you can also use the Memory Analyzer Tool (MAT) provided by Eclipse to replace these tools.
Another tool, ThreadDumpViewer, is rare and is also a free tool for analyzing ThreadDump. This is also true.
5) If you are developing server applications or other O & M-related applications and want to provide you with ThreadDump information, you must use the program to control them, now it is more flexible:
A: You can use 3 ).
B: You can also use the Java Runtime API to execute the commands mentioned above 2.