java 分析java进程的线程转储
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11346807/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Analyzing thread dump of a java process
提问by peakit
I have Java EE based application running on tomcat and I am seeing that all of a sudden the application hangs after running for couple of hours.
我在 tomcat 上运行基于 Java EE 的应用程序,我看到应用程序在运行几个小时后突然挂起。
I collected the thread dump from the application just before it hangs and put it in TDA for analysis:
我在应用程序挂起之前收集了线程转储并将其放入 TDA 进行分析:
TDA(Thread Dump Analyzer) gives the following message for the above monitor:
TDA(线程转储分析器)为上述监视器提供以下消息:
A lot of threads are waiting for this monitor to become available again.
This might indicate a congestion. You also should analyze other locks
blocked by threads waiting for this monitor as there might be much more
threads waiting for it.
And here is the stacktrace of the thread highlighted above:
这是上面突出显示的线程的堆栈跟踪:
"MY_THREAD" prio=10 tid=0x00007f97f1918800 nid=0x776a
waiting for monitor entry [0x00007f9819560000]
java.lang.Thread.State: BLOCKED (on object monitor)
at java.util.Hashtable.get(Hashtable.java:356)
- locked <0x0000000680038b68> (a java.util.Properties)
at java.util.Properties.getProperty(Properties.java:951)
at java.lang.System.getProperty(System.java:709)
at com.MyClass.myMethod(MyClass.java:344)
I want to know what does the "waiting for monitor entry"
state means? And also would appreciate any pointers to help me debug this issue.
我想知道"waiting for monitor entry"
状态是什么意思?并且也很感激任何帮助我调试这个问题的指针。
回答by maestr0
One of your threads acquired a monitor object (an exclusive lock on a object). That means the thread is executing synchronized code and for whatever reason stuck there, possibly waiting for other threads. But the other threads cannot continue their execution because they encountered a synchronized block and asked for a lock (monitor object), however they cannot get it until it is released by other thread. So... probably deadlock.
您的一个线程获取了一个监视器对象(对象上的排它锁)。这意味着该线程正在执行同步代码,并且无论出于何种原因卡在那里,可能正在等待其他线程。但是其他线程无法继续执行,因为它们遇到了同步块并要求锁定(监视对象),但是在其他线程释放之前它们无法获取它。所以……可能是僵局。
回答by bobon
Please look for this string from the whole thread dump
请从整个线程转储中查找此字符串
- locked <0x00007f9819560000>
- 锁定 <0x00007f9819560000>
If you can find it, the thread is deadlock with thread "tid=0x00007f97f1918800"
如果能找到,说明线程死锁,线程“tid=0x00007f97f1918800”
回答by ControlAltDel
Monitor = synchronized. You have lots of threads trying to get the lock on the same object.
监视器 = 同步。您有很多线程试图获取同一个对象的锁。
Maybe you should switch from using a Hashtable and use a HashMap
也许你应该从使用 Hashtable 切换到使用 HashMap
回答by mprivat
This means that your thread is trying to set a lock (on the Hashtable), but some other thread is already accessing it and has set a lock. So it's waiting for the lock to release. Check what your other threads are doing. Especially thread with tid="0x00007f9819560000"
这意味着您的线程正在尝试设置锁(在 Hashtable 上),但其他一些线程已经在访问它并设置了锁。所以它在等待锁释放。检查您的其他线程在做什么。特别是 tid="0x00007f9819560000" 的线程