找最耗CPU的线程

1. 找出java进程

[ ~]# jps
9939 Resin
9874 WatchdogManager
9926 Jps

2. 找java进程下所有的线程  

[ ~]# top -Hp 9939 -n 1
top - 17:45:17 up 40 days, 7:11, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 405 total, 0 running, 405 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.3%us, 0.3%sy, 0.0%ni, 99.3%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 16331812k total, 4357204k used, 11974608k free, 287632k buffers
Swap: 6291452k total, 0k used, 6291452k free, 2663424k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1399 root 20 0 5418m 822m 23m S 2.0 5.2 0:00.50 java
9939 root 20 0 5418m 822m 23m S 0.0 5.2 0:00.00 java
9941 root 20 0 5418m 822m 23m S 0.0 5.2 0:35.07 java
9942 root 20 0 5418m 822m 23m S 0.0 5.2 1:34.61 java
9943 root 20 0 5418m 822m 23m S 0.0 5.2 1:34.17 java
9944 root 20 0 5418m 822m 23m S 0.0 5.2 1:34.37 java

3. nid 1399 的16进制

[ ~]# printf '%x\n' 1399
577

4. 找java线程  

[ ~]# jstack 9939 | grep 577
"resin-port-127.0.0.1:35080-launcher" daemon prio=10 tid=0x00007fa6b805d000 nid=0x577 waiting on condition [0x00007fa5ddd98000]

5. 找代码  

  

05-08 14:56