SwingWorker is a popular utility class developed by Sun Microsystems for the Swing library of the Java programming language. SwingWorker enables proper use of the event dispatching thread. As of Java 6, SwingWorker is included in the JRE. Several incompatible, unofficial, versions of SwingWorker were produced from 1998 to 2006, and care must be taken to avoid the abundant documentation on these versions predating Java 6. Usage in Java 6.0 The event dispatching thread problem SwingWorker is useful when a time-consuming task has to be performed following a user-interaction event (for example, parsing a huge XML File, on pressing a JButton). The most straightforward way to do it is : private Document doc; ... JButton button = new JButton("Open XML"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doc = loadXML(); } }); This will work, but unfortunately, the loadXML() method will be called in the same thread as the main Swing thread (the Event dispatching thread), so if the method needs time to perform, the GUI will freeze during this time. SwingWorker solution This problem is not specific to Java, but common to many GUI models. SwingWorker proposes a way to solve it by performing the time-consuming task on another background thread, keeping the GUI responsive during this time. Creating the worker The following code defines the SwingWorker, which encapsulates the loadXML() method call : SwingWorker worker = new SwingWorker<Document, Void>() { @Override public Document doInBackground() { Document intDoc = loadXML(); return intDoc; } }; Worker execution Execution is started by using the method. Retrieving the result The result can be retrieved by using the method. As calling on the Event Dispatch Thread blocks all events, including repaints, from being processed until the task completes, one must avoid calling it before the lengthy operation has finished. There are two ways to retrieve the result after the task completion : override the method. This method is called on the main event dispatching thread. private Document doc; ... SwingWorker<Document, Void> worker = new SwingWorker<Document, Void>() { @Override public Document doInBackground() { Document intDoc = loadXML(); return intDoc; } @Override public void done() { try { doc = get(); } catch (InterruptedException ex) { ex.printStackTrace(); } catch (ExecutionException ex) { ex.printStackTrace(); } } } register a listener by using the worker method. The listener will be notified of changes in the worker state. Complete Worker example private Document doc; ... JButton