15.6. Swing Threads
Swing follows the familiar AWT event model and uses a single-threaded design for updating components. Recall from Chapter 11 (Handling Mouse and Keyboard Events) that painting of components and handling of listeners are both processed in a single event dispatch thread. As a consequence of the event model, two general rules apply for robust GUI design:
If tasks in the event handling method require considerable CPU time, then execute these time-intensive tasks in a separate thread. Freeing the event dispatch thread to process other queued events yields a more responsive user interface.
Make changes to the state of a realized (visible) Swing component only within the event dispatch thread and not within a user-defined thread. ...