The attached program ains to generate the situation which LogManager initialization and JVM termination
runs at the same time.
This program generates deadlock easiliy.
REPRODUCE:
Compile the attached "test.java" and invoke "java test"
You will see program does not return.
LOG :
The following is thread dump.
=====================
K:\shares2\dead-lock-jvminit-logmngrinit>java test
Full thread dump Java HotSpot(TM) Client VM (1.5.0_08-b03 mixed mode):
"Thread-1" prio=6 tid=0x00ab6df0 nid=0xefc in Object.wait() [0x0ad1f000..0x0ad1f
b68]
at java.util.logging.LogManager$Cleaner.run(LogManager.java:204)
- waiting to lock <0x02b10238> (a java.util.logging.LogManager)
"Thread-0" prio=6 tid=0x00ab7070 nid=0x50c in Object.wait() [0x0acdf000..0x0acdf
be8]
at java.lang.Object.wait(Native Method)
- waiting on <0x02b10370> (a java.util.logging.LogManager$Cleaner)
at java.lang.Thread.join(Thread.java:1095)
- locked <0x02b10370> (a java.util.logging.LogManager$Cleaner)
at java.lang.Thread.join(Thread.java:1148)
at java.lang.Shutdown.runHooks(Shutdown.java:132)
at java.lang.Shutdown.sequence(Shutdown.java:173)
at java.lang.Shutdown.exit(Shutdown.java:218)
- locked <0x06c8f310> (a java.lang.Class)
at java.lang.Runtime.exit(Runtime.java:90)
at java.lang.System.exit(System.java:869)
at test.run(test.java:29)
at java.lang.Thread.run(Thread.java:595)
"Low Memory Detector" daemon prio=6 tid=0x00aa42f8 nid=0xdf4 runnable [0x0000000
0..0x00000000]
"CompilerThread0" daemon prio=10 tid=0x00ac4c00 nid=0x1e8 waiting on condition [
0x00000000..0x0ac1f6c8]
"Signal Dispatcher" daemon prio=10 tid=0x00ac4008 nid=0x5c4 waiting on condition
[0x00000000..0x00000000]
"Finalizer" daemon prio=8 tid=0x00a98b30 nid=0x99c in Object.wait() [0x0ab9f000.
.0x0ab9fa68]
at java.lang.Object.wait(Native Method)
- waiting on <0x02ae06e0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
- locked <0x02ae06e0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
"Reference Handler" daemon prio=10 tid=0x00a976c8 nid=0xbc in Object.wait() [0x0
ab5f000..0x0ab5fae8]
at java.lang.Object.wait(Native Method)
- waiting on <0x02ae05f0> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:474)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
- locked <0x02ae05f0> (a java.lang.ref.Reference$Lock)
"main" prio=6 tid=0x000359b8 nid=0xfc8 waiting for monitor entry [0x0007f000..0x
0007fc3c]
at java.util.logging.LogManager.addLogger(LogManager.java:322)
- waiting to lock <0x02b10238> (a java.util.logging.LogManager)
at java.util.logging.LogManager$1.run(LogManager.java:180)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.logging.LogManager.<clinit>(LogManager.java:156)
at test.main(test.java:14)
"VM Thread" prio=10 tid=0x00a94c00 nid=0xf5c runnable
"VM Periodic Task Thread" prio=10 tid=0x00aa54c8 nid=0xd60 waiting on condition
====================