View the highest thread java procedures cpu usage under linux

Ideas:

1. Locate the process corresponding java program (ps or top or jps (root privileges)) such as pid is 20830

2. Find the corresponding thread uses most cpu ps process according to the parameters related to the thread view

3. Print out all the java command threads with jstack 

The thread id found in step 2 into a message hex jstack printed to find the corresponding thread

5. According to deal with the corresponding threads corresponding stackTrace java

ps related commands

-p 20830 -mfL PS | Sort -rk. 5 | head. 3 -n | tail -n. 1 | awk '{}. 4 Print $' | xargs the printf '% X \ n-'
jstack related commands

/opt/jdk/jdk1.8.0_221/bin/jstack 20830

Guess you like

Origin www.cnblogs.com/zhangyy3/p/11465779.html