Concurrency & Swing
It is easy to forget that you are using threads when you program with Swing. The fact that you don’t have to explicitly create a Thread object means that threading issues can catch you by surprise. Typically, when you write a Swing program, or any GUI application with a windowed display, the majority of the application is event driven, and nothing really happens until the user generates and event by clicking on a GUI component with the mouse, or striking a key.
Just remember that there is a Swing event dispatching thread, which is always there, handling all the Swing events in turn. This needs to be considered if you want to guarantee that your application won’t suffer from deadlocking or race conditions.
This section looks at a couple of issues worth noting when working with threads under Swing.