在 sun.misc.Unsafe.park 等待(本地方法) [英] WAITING at sun.misc.Unsafe.park(Native Method)

查看:350
本文介绍了在 sun.misc.Unsafe.park 等待(本地方法)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个应用程序在一段时间内在负载下运行时挂起,有没有人知道什么会导致 jstack 中出现这样的输出:

One of my applications hangs under some period of running under load, does anyone know what could cause such output in jstack:

"scheduler-5" prio=10 tid=0x00007f49481d0000 nid=0x2061 waiting on condition [0x00007f494e8d0000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000006ee117310> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1085)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:807)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1103)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

当它挂起时,我在 jstack 输出中看到了很多.

I am seeing this a lot in jstack output when it hangs.

我大量使用 Spring @Async &地图、同步地图和ehcache.

I heavily using Spring @Async & maps, synchronized maps & ehcache.

有趣的是,这只发生在一个应用程序实例上.另外两个运行得很好.在这种情况下,我还能调查什么以获得更多详细信息?

What is interesting this only happens on one of app instances. Two others are running perfectly fine. What else I could investigate to get more details in such case?

我发现这篇文章https://stackoverflow.com/questions/23992787/parking-to-wait-for-0xd8cf0070-a-java-util-concurrent-locks-abstractqueueds 但对我来说它不是很有用.

I found this post https://stackoverflow.com/questions/23992787/parking-to-wait-for-0xd8cf0070-a-java-util-concurrent-locks-abstractqueueds but it is not very useful in my case.

推荐答案

unsafe.park 与 thread.wait 几乎相同,不同之处在于它使用特定于体系结构的代码(因此它是不安全的").unsafe 未公开提供,但在 Java 内部库中使用,其中体系结构特定代码将提供显着的优化优势.大量用于线程池.

unsafe.park is pretty much the same as thread.wait, except that it's using architecture specific code (thus the reason it's 'unsafe'). unsafe is not made available publicly, but is used within java internal libraries where architecture specific code would offer significant optimization benefits. It's used a lot for thread pooling.

所以,为了回答你的问题,所有线程正在做的就是等待某事,它并没有真正使用任何 CPU.考虑到您的原始堆栈跟踪显示您正在使用锁,我认为您的情况正在发生死锁.

So, to answer your question, all the thread is doing is waiting for something, it's not really using any CPU. Considering that your original stack trace shows that you're using a lock I would assume a deadlock is going on in your case.

是的,我知道您现在几乎可以肯定已经解决了这个问题.但是,如果有人在 google 上搜索 sun.misc.unsafe.park,您就是最佳搜索结果之一.我想回答这个问题可能会帮助其他人试图理解这种似乎正在使用他们所有 CPU 的方法是什么.

Yes I know you have almost certainly already solved this issue by now. However, you're one of the top results if someone googles sun.misc.unsafe.park. I figure answering the question may help others trying to understand what this method that seems to be using all their CPU is.

这篇关于在 sun.misc.Unsafe.park 等待(本地方法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆