I am writing a Java Web Start application and I have observed it freezing. When I do a thread dump, I can see the two threads involved in the deadlock are both Event Dispatch Threads.
When I run the app locally, there is only one EDT, but when I download and run through Java Web Start, there is a second one.
Can someone tell me why there is a second EDT, and how can I prevent them deadlocking with each other?
edit: After monitoring the app using JVisualVM, I believe that the second EDT is responsible for redrawing the java console window.
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)