Java threads waiting to lock an object that is not (apparently) locked

Usually, when I request a thread dump, the symptoms of a poorly executed system are easily explained; that is, as a rule, I could see that several threads are clearly waiting on a monitor that was purchased but not released by another.

In this case, I have many threads waiting for a monitor (0x965ad100), but it seems that none of them have this monitor. These topics can be identified using this signature:

Waiting for a lock <0x965ad100> (a uk.gov.dti.og.fox.ConAgent)

I tried Google for this, and all I seem to find is messages that discuss locked monitors, nothing about waiting for a monitor that is not locked.

Full Reset Threads: http://www.basson.at/docs/stackoverflow/thread_dump.txt

I hope someone here can explain what I see, or at least point me in the right direction. Thanks in advance for any answers.

+6
java multithreading locking dump monitor
source share
2 answers

It is possible (though unlikely) that the stream just released the monitor when your stream dump was made. There may be a short period between when the monitor is released and the next thread will receive it. If you are not in a real dead end, this may explain what you see. Try another stream dump and check it out.

Most likely, there is a thread where the monitor is already located. Sometimes this is not obvious. The stack trace has some "locked" lines that list threads that contain certain locks, but this list is not necessarily complete. For example, I suspect that locks received through the JNI are not specified.

If you can replace the built-in lock, for example. java.util.concurrent.locks.ReentrantLock , you can pause the program and apply a debugger, find the lock you care about and find the owner of the lock using the getOwner method.

+1
source share

If you use Eclipse, you can use the built-in lock viewer through the Debug view, which can be useful. You can enable it using the drop-down menu available with the down arrow on the toolbar :)

alt text

+1
source share

All Articles