I get a dead end in the Swing application that I support, and although I have a workaround that seems to work, I'm not sure that I understood what I was doing and didnโt just hide the race status, it might appear later.
A thread trace indicates that a deadlock occurs between the two AWT-EventQueue-0 and AWT-EventQueue-1 threads. My first question is which one is a shameful Dispatching Thread event. Both threads have the bottom of the stack trace:
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
I think the root of the problem is that application classes mix domain data with graphical components, in which case both threads try to block both java.awt.Component$AWTTreeLock and one of my own objects (say, X). My workaround is to use SwingUtilities.invokeLater() in one place where X is locked, although this is already on EDT. According to Javadoc, this means that the call is โdeferred until all incomplete events are processed.โ However, I'm not quite sure if this is really a solution, and in any case, I don't understand why there seem to be two EDTs.
Can anyone explain what is happening? I can try to provide an abbreviated version of the code, but it may take me some time to edit the unulocal complications.
source share