Section 23.11 Multithreading with GUI: SwingWorker

• The event dispatch thread (p. 1011) handles interactions with the application’s GUI components. All tasks that interact with the GUI are placed in an event queue and executed sequentially by this thread.

• Swing GUI components are not thread safe. Thread safety is achieved by ensuring that Swing components are accessed from only the event dispatch thread.

• Performing a lengthy computation in response to a user interface interaction ties up the event dispatch thread, preventing it from attending to other tasks and causing the GUI components to become unresponsive. Long-running computations should be handled in separate threads.

• You can extend generic class SwingWorker (package javax.swing ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.