分享

ExecutorService负载很高,锁在一个资源上

 hh3755 2015-06-12

最近新写一个程序发现负载很高,不知原因,故使用jstack将线程信息打印出来。找到给900多个等待如下资源的线程:

- parking to wait for  <0x00007f126138b7e0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)

查了一圈资料,好像是说在等队列进来,难道是线程池单纯太大,引起上下文切换和管理引起的CPU高?!

I noticed that my java application (runs on tomcat6) spawns a lot of threads which do not terminate.

So I created a thread dump and noticed that there are tons of threads waiting, like this:

"pool-1-thread-22" prio=5 tid=101b4b000 nid=0x127122000 waiting on condition [127121000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <6c340cee0> (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:680)
   Locked ownable synchronizers:
    - None

Now the question is: WHAT are these threads waiting for? I have suspect class which seems to spawn these threads but I don't know what exactly is making these threads stuck.

Is there anything I can do to find the cause for this except for tearing the class apart line by line and keep monitoring thread behavior?

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多