我正在编写一个 Java Web Start 应用程序,我观察到它冻结了。当我进行线程转储时,我可以看到死锁中涉及的两个线程都是事件调度线程。
当我在本地运行应用程序时,只有一个 EDT,但是当我下载并通过 Java Web Start 运行时,还有第二个。
有人能告诉我为什么会有第二个 EDT,我怎样才能防止它们相互僵持?
编辑:使用JVisualVM监控应用程序后,我相信第二个EDT负责重绘java控制台窗口。
Found one Java-level deadlock:
=============================
"AWT-EventQueue-1":
waiting to lock monitor 0x07e4d8fc (object 0x29c2d950, a java.awt.Component$AWTTreeLock),
which is held by "AWT-EventQueue-0"
"AWT-EventQueue-0":
waiting to lock monitor 0x07e4cbfc (object 0x29c294e8, a java.lang.StringBuilder),
which is held by "AWT-EventQueue-1"
Java stack information for the threads listed above:
===================================================
"AWT-EventQueue-1":
at java.awt.Window.getOpacity(Unknown Source)
- waiting to lock <0x29c2d950> (a java.awt.Component$AWTTreeLock)
at sun.awt.SunToolkit.isContainingTopLevelTranslucent(Unknown Source)
at sun.awt.windows.WComponentPeer.isAccelCapable(Unknown Source)
at sun.java2d.d3d.D3DSurfaceData$D3DWindowSurfaceData.restoreSurface(Unknown Source)
at sun.java2d.d3d.D3DScreenUpdateManager.validate(Unknown Source)
at sun.java2d.d3d.D3DScreenUpdateManager.createGraphics(Unknown Source)
at sun.awt.windows.WComponentPeer.getGraphics(Unknown Source)
at java.awt.Component.getGraphics(Unknown Source)
at javax.swing.JFrame.getGraphics(Unknown Source)
at javax.swing.JComponent.safelyGetGraphics(Unknown Source)
- locked <0x29c294e8> (a java.lang.StringBuilder)
at javax.swing.RepaintManager$3.run(Unknown Source)
...
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
"AWT-EventQueue-0":
at javax.swing.JComponent.isComponentObtainingGraphicsFrom(Unknown Source)
- waiting to lock <0x29c294e8> (a java.lang.StringBuilder)
at javax.swing.JComponent.getGraphicsInvoked(Unknown Source)
at javax.swing.JFrame.getGraphics(Unknown Source)
...
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)