I\'m getting a deadlock in the Swing application I maintain, and although I have a workaround that appears to work, I\'m not sure that I have understood what I am doing and have
Thanks to Yishai for pointing me in the right direction. The application is instantiating its own subclass of java.awt.EventQueue
and using Toolkit.getDefaultToolkit().getSystemEventQueue().push(newQueue)
to replace the original queue. The original queue must still be processing a task on its thread, AWT-EventQueue-0
at the same time as events start arriving in the new queue on thread AWT-EventQueue-1
, resulting in deadlock.
Are you creating threads anywhere? If yes, consider to use
http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingWorker.html
or
http://docs.oracle.com/javase/7/docs/api/javax/swing/Timer.html
instead which work well with Swing.