1. Through top, find the process ID that consumes high CPU
2.
As shown in Java, the process ID is ' 52554′, and then the top command is used to monitor all threads in the process separately:
top
-p52554 -H
3, (then see which Java thread CPU high, which thread memory used more)
4.
As shown in Linux, all Java internal threads actually correspond to a process ID, which means that the Sun JVM on Linux maps threads in Java programs for operating system processes, and we see that the process ID that consumes the most CPU resources is ' 15417′, This process ID corresponds to the ' Nid ' (' n ' stands for ' native ') in the Java thread information;
5, to find out exactly which part of the specific code occupies so many resources, first use Jstack to play the current stack information into a file, such as Stack.log:
- Jstack 52554 > stack. Log
- Python-c
"print hex(9757)"然后记住二进制的号
cat stack.log|grep 二进制的号
Linux a thread that consumes high CPU in a process