檢視和診斷JVM執行緒資訊

Jet_Zhang發表於2016-07-25

JVM自帶的工具jstack是用來檢視JVM執行緒資訊的利器,尤其在診斷CPU 100%的時候非常有用。

使用方法:

$JAVA_HOME/bin/jstack pid

例:/usr/tomcat55/jdk1.6.0_27/bin/jstack 24189

Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.2-b06 mixed mode):

"Attach Listener" daemon prio=10 tid=0x0000000042835000 nid=0x7227 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE

"http-8080-Processor800" daemon prio=10 tid=0x0000000042cbd800 nid=0x70fc in Object.wait() [0x000000004ad51000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:657)
- locked <0x000000078ece70a8> (a org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)
at java.lang.Thread.run(Thread.java:662)

"http-8080-Processor799" daemon prio=10 tid=0x0000000042887000 nid=0x70fb in Object.wait() [0x0000000046408000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:657)
- locked <0x000000078ec2f1f8> (a org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)
at java.lang.Thread.run(Thread.java:662)

"http-8080-Processor796" daemon prio=10 tid=0x0000000042b3f000 nid=0x70f8 in Object.wait() [0x000000004c86c000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:657)
- locked <0x000000078ed3c330> (a org.apache.tomcat.util.threads.ThreadPool$ControlRunnable)
at java.lang.Thread.run(Thread.java:662)

...

jstack需要安裝JDK才能使用。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/13885898/viewspace-2122504/,如需轉載,請註明出處,否則將追究法律責任。

相關文章