Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Analyzing thread dump of a java process

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.

I collected the thread dump from the application just before it hangs and put it in TDA for analysis:

enter image description here

TDA (Thread Dump Analyzer) gives the following message for the above monitor:

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.

like image 254
peakit Avatar asked Jul 05 '12 14:07

peakit


2 Answers

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.

like image 153
maestr0 Avatar answered Sep 27 '22 17:09

maestr0


Please look for this string from the whole thread dump

- locked <0x00007f9819560000>

If you can find it, the thread is deadlock with thread "tid=0x00007f97f1918800"

like image 33
bobon Avatar answered Sep 27 '22 17:09

bobon