An example of the LOCKS component part of a Javadump taken during a deadlock.
A lock, also referred to as a monitor, prevents more than one entity from accessing a shared resource. Each object in Java™ has an associated lock, obtained by using a synchronized block or method. In the case of the JVM, threads compete for various resources in the JVM and locks on Java objects.
This example was taken from a deadlock test program where two threads “DeadLockThread 0” and “DeadLockThread 1” were unsuccessfully attempting to synchronize (Java keyword) on two java/lang/Integers.
You can see in the example (highlighted) that “DeadLockThread 1” has locked the object instance java/lang/Integer@004B2290. The monitor has been created as a result of a Java code fragment looking like “synchronize(count0)”, and this monitor has “DeadLockThread 1” waiting to get a lock on this same object instance (count0 from the code fragment). Below the highlighted section is another monitor locked by “DeadLockThread 0” that has “DeadLockThread 1” waiting.
This classic deadlock situation is caused by an error in application design; Javadump is a major tool in the detection of such events.
------------------------------------------------------------------------ LOCKS subcomponent dump routine =============================== Monitor pool info: Current total number of monitors: 2 Monitor Pool Dump (flat & inflated object-monitors): sys_mon_t:0x00039B40 infl_mon_t: 0x00039B80: java/lang/Integer@004B22A0/004B22AC: Flat locked by "DeadLockThread 1" (0x41DAB100), entry count 1 Waiting to enter: "DeadLockThread 0" (0x41DAAD00) sys_mon_t:0x00039B98 infl_mon_t: 0x00039BD8: java/lang/Integer@004B2290/004B229C: Flat locked by "DeadLockThread 0" (0x41DAAD00), entry count 1 Waiting to enter: "DeadLockThread 1" (0x41DAB100) JVM System Monitor Dump (registered monitors): Thread global lock (0x00034878): <unowned> NLS hash table lock (0x00034928): <unowned> portLibrary_j9sig_async_monitor lock (0x00034980): <unowned> Hook Interface lock (0x000349D8): <unowned> < lines removed for brevity > ======================= Deadlock detected !!! --------------------- Thread "DeadLockThread 1" (0x41DAB100) is waiting for: sys_mon_t:0x00039B98 infl_mon_t: 0x00039BD8: java/lang/Integer@004B2290/004B229C: which is owned by: Thread "DeadLockThread 0" (0x41DAAD00) which is waiting for: sys_mon_t:0x00039B40 infl_mon_t: 0x00039B80: java/lang/Integer@004B22A0/004B22AC: which is owned by: Thread "DeadLockThread 1" (0x41DAB100)