我刚刚从 Oracle JDK 1.6 切换到 Open JDK 1.7.0_03,并且在退出时遇到了一个相当显着的死锁:
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.Thread.join(Thread.java:1258)
- locked <0x8608dda0> (a sun.awt.X11.XToolkit$1$1)
at java.lang.Thread.join(Thread.java:1332)
at java.lang.ApplicationShutdownHooks.runHooks(ApplicationShutdownHooks.java:106)
at java.lang.ApplicationShutdownHooks$1.run(ApplicationShutdownHooks.java:46)
at java.lang.Shutdown.runHooks(Shutdown.java:123)
at java.lang.Shutdown.sequence(Shutdown.java:167)
at java.lang.Shutdown.exit(Shutdown.java:212)
- locked <0x8603df28> (a java.lang.Class for java.lang.Shutdown)
at java.lang.Runtime.exit(Runtime.java:107)
at java.lang.System.exit(System.java:960)
看来您必须从 AWT 事件队列中调用 System.exit。这是真的吗?Sun docs Runtime.exit中没有关于线程要求的文档
我遇到了其他令人惊讶的情况,即仅在 Linux 上才需要获取 AWT 树锁,但这个情况很重要。这是一个错误,还是我只是错过了文档中的某些内容?