Chinaunix首页 | 论坛 | 博客
  • 博客访问: 507353
  • 博文数量: 158
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 904
  • 用 户 组: 普通用户
  • 注册时间: 2016-10-10 11:17
文章分类

全部博文(158)

文章存档

2018年(74)

2017年(84)

我的朋友

分类: Java

2018-08-16 17:28:46

线程问题的分析步骤:

1、使用top命令查看系统资源占用情况,发现Java进程占用大量CPU资源,PID为11572;

2、显示进程详细列表命令:ps -mp 11572 -o THREAD,tid,time

找到消耗资源多的TID,如TID:112052

 3、将TID转换成16进制:printf "%x\n" 12052

 

4、打印堆栈信息:jstack 11572 |grep 2f14 -A 30

 

Thread dump信息如下:

"thread1" prio=6 tid=0x02de8400 nid=0x2688 runnable [0x0320f000]

   java.lang.Thread.State: RUNNABLE

    at DeadLock.callLongTime(DeadLock.java:63)

    at DeadLock$2.run(DeadLock.java:41)

    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)

    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

    at java.util.concurrent.FutureTask.run(FutureTask.java:166)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

    at java.lang.Thread.run(Thread.java:722)

 

   Locked ownable synchronizers:

    - <0x22be1488> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)

 

"thread2" prio=6 tid=0x02de6c00 nid=0x218c waiting on condition [0x031bf000]

   java.lang.Thread.State: WAITING (parking)

    at sun.misc.Unsafe.park(Native Method)

    - parking to wait for  <0x22be1488> (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 DeadLock$2.run(DeadLock.java:40)

    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)

    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

    at java.util.concurrent.FutureTask.run(FutureTask.java:166)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

    at java.lang.Thread.run(Thread.java:722)

 

   Locked ownable synchronizers:

    - <0x22be64e0> (a java.util.concurrent.ThreadPoolExecutor$Worker)

 

          线程“thread2”处于WAITING状态,- parking to wait for  <0x22be1488>,等待给0x22be1488的地址,而0x22be1488地址正被“thread1”上锁,Dump日志中有大量线程等待给这个地址上锁,就会出现线程等待资源超时。

阅读(10250) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~