First step, find out the Java process PID
PS grep Process name keyword
This assumes that the PID found is: 12345
Step two, find the most CPU-consuming thread in the process
Top-hp1234517183log4x - 0 4292820 529812 23040R94.7 0.8 1:11.79java-server-xms268435456-xmx26843545617162log4x - 0 4292820 529812 23040R87.1 0.8 1:17.90java-server-xms268435456-xmx26843545617172log4x - 0 4292820 529812 23040R86.1 0.8 1:16.26java-server-xms268435456-xmx26843545617176log4x - 0 4292820 529812 23040R68.0 0.8 1:12.31java-server-xms268435456-xmx26843545617170log4x - 0 4292820 529812 23040S7.3 0.8 0:44.70java-server-xms268435456-xmx268435456
Step three, convert the thread number to hexadecimal
" %x\n " 17183 431f
Fourth step, use Jstack pid to print out all the thread stacks in the process
12345 12345. txt
The fifth step, based on the hexadecimal encoding of the thread, locates the specific thread stack in the stack file.
nid=0x431f
How can I quickly locate the most CPU consuming thread in the JVM?