By aalmiray
via pushing-pixels.org
Published: Dec 08 2007 / 16:01
The threading rules in Swing are one of the main reasons for the perceived slowness of Java desktop applications (it remains to be seen whether JavaFX will address this issue for anything other than toy demo applications that have started appearing lately). This article by John Zukowski is an excellent overview of the threading rules in Swing since its inception, and how to write applications that do not break the thread safety.
All different EDT-related rules pretty much boil down to one simple thing - anything that affects pixels on the screen should be done on EDT. However, these rules are all concerned about the where and not the when. And the when is very important.



Comments
Eric Burke replied ago:
While the points about EDT are fine, recommending SwingUtilities.invokeLater on every button click seems like bad advice.
Kirill Grouchnikov replied ago:
Bad as in "producing incorrect runtime behavior"?
Voters For This Link (12)
Voters Against This Link (1)