>>My workaround, which has been generally successful, was to subclass
>>JFrame. In the subclass I override dispose (and also setVisible())
>>with a method that forks off Thread with a lower priority than the
>>current thread.
That's a clever workaround, but ugh!
>Is Nelson's application multi-threaded?
Yep, heavily.
>I'm pretty new to this Java game, but it appears to me that the AWT's
>dirty little secret is a lack of thread safety.
AWT's threading is very strange and complicated (and update runs at
the wrong priority), but I've never seen it do something unsafe. My
impression is this is more like a Peer problem, that maybe the Peer
implementation isn't safe.
>The closest thing I've found to relevant information is in the
>documentation for Swing -- which states explicitly that Swing is not
>thread-safe, and that all GUI access, after the GUI is instantiated,
>needs to happen from the AWT Event thread.
This is certainly a requirement I can live with. But in this case,
the dispose() only happens in an AWT Event thread. It's called when
the user clicks on a button (stackframe included again)
>On the other hand, I've found that adopting Swing's approach has
>solved my GUI reliability problems. Norm's approach sounds
>suspiciously similar.
Actually, isn't it exactly the opposite, putting the call to Swing
in some non-Swing thread?
Here's that stack trace again -
"AWT-EventQueue-0" (TID:0x407209c0, sys_thread_t:0x4154bf04, state:R) prio=5
*current thread*
sun.awt.motif.MComponentPeer.dispose(MComponentPeer.java:215)
sun.awt.motif.MFramePeer.dispose(MFramePeer.java:101)
java.awt.Component.removeNotify(Component.java:2526)
java.awt.Container.removeNotify(Container.java:1149)
java.awt.Window.dispose(Window.java:177)
java.awt.Frame.dispose(Frame.java:372)
edu.mit.media.nelson.straum.agent.CreateAgentUI.createAgent(CreateAgentUI.java:70)
edu.mit.media.nelson.straum.agent.CreateAgentUI$2.actionPerformed(CreateAgentUI.java:45)
java.awt.Button.processActionEvent(Button.java:254)
java.awt.Button.processEvent(Button.java:227)
java.awt.Component.dispatchEventImpl(Component.java:1764)
java.awt.Component.dispatchEvent(Component.java:1704)
java.awt.EventDispatchThread.run(EventDispatchThread.java:63)