后补:
假如条件允许的话,最好引入arthas查看线程:https://arthas.aliyun.com/doc/thread.html
第一步:查找占用CPU最高的进程id
top
第二步:把该进程中占用CPU最高的线程输出到文件:/tmp/cpu_tid.log
top -Hp <最高pid> -b -n 3 -d 3 >> /tmp/cpu_tid.log
<最高pid>:把第一步查找的最高的pid输入
-b:batch模式,可以重定向到文件中
-n 3:一共取3次top数据。后边加数字,表示次数
-d 3:每次top时间间隔是3秒钟
第三步:把jvm线程堆栈输出到文件:/tmp/jstack.log
sudo /usr/local/jdk1.8.0_212/bin/jstack -l <最高pid> >> /tmp/jstack.log
<最高pid>:把第一步查找的最高的pid输入
第四步:查找占用最高的线程的堆栈信息
cat /tmp/jstack.log | grep `printf "%x\n" <tid>` -A 10
<tid>:把第二步查找的tid输入即可