top命令找到占用CPU最高的java线程

参考 http://lxiaodao.iteye.com/blog/1413774

和长源

28147是java的进程号,通过jps命令查出来的

top -Hp 28174 -d 1 -n 1  

查出占CPU最高的线程

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                          
20765 admin     22   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             
20766 admin     18   0 1628m 1.3g  15m S  0.0 17.5   0:00.62 java                                                                             
20767 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:27.16 java                                                                             
20768 admin     16   0 1628m 1.3g  15m S  0.0 17.5   0:27.40 java                                                                             
20769 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:27.77 java                                                                             
20770 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:27.52 java                                                                             
20771 admin     16   0 1628m 1.3g  15m S  0.0 17.5   0:27.63 java                                                                             
20772 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:15.18 java                                                                             
20773 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             
20774 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             
20775 admin     19   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             
20776 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:11.21 java                                                                             
20777 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:09.81 java                                                                             
20778 admin     25   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             
20779 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             
20783 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:00.03 java                                                                             
20784 admin     19   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             
20785 admin     20   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             
20786 admin     21   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java 

20766是最耗CPU的线程,转换成16进制511e,再用jstack命令查看线程堆栈

[admin@v022067 ~/logs]$ jstack -l 20765 | grep 511e -A 20     
"DestroyJavaVM" prio=10 tid=0x00002aaab4268800 nid=0x511e waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
        - None

"pool-3-thread-1" prio=10 tid=0x00002aaab4344000 nid=0x5138 waiting on condition [0x00000000428ad000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000000c01259f0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
        at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:399)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:662)

   Locked ownable synchronizers:
        - None

"main-EventThread" daemon prio=10 tid=0x0000000043bce800 nid=0x5137 waiting on condition [0x00000000427ac000]



你可能感兴趣的:(java)