码迷,mamicode.com
首页 > Web开发 > 详细

jstack,用于检测死锁

时间:2015-05-31 16:58:17      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

  命令:jstack 进程号

 用于检测线程是否存在死锁,通过打印出jvm线程栈来进行跟踪 

实例:

Found one Java-level deadlock:
=============================
"Thread-1":
  waiting for ownable synchronizer 0x00000007d6e6dab8, (a java.util.concurrent.locks.ReentrantLock$NonfairSync),
  which is held by "Thread-0"
"Thread-0":
  waiting for ownable synchronizer 0x00000007d6e6dae8, (a java.util.concurrent.locks.ReentrantLock$NonfairSync),
  which is held by "Thread-1"


Java stack information for the threads listed above:
===================================================
"Thread-1":
at sun.misc.Unsafe.park(Native Method)
- parking to wait for  <0x00000007d6e6dab8> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:214)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:290)
at com.test.jdk.DeadLockTest$2.run(DeadLockTest.java:40)
at java.lang.Thread.run(Thread.java:745)
"Thread-0":
at sun.misc.Unsafe.park(Native Method)
- parking to wait for  <0x00000007d6e6dae8> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:214)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:290)
at com.test.jdk.DeadLockTest$1.run(DeadLockTest.java:21)
at java.lang.Thread.run(Thread.java:745)


Found 1 deadlock.


可以发现线程1和线程0形成了死锁。

jstack,用于检测死锁

标签:

原文地址:http://blog.csdn.net/zhaozhenzuo/article/details/46289053

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!