button = new JButton("Open XML"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { 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(); } } }; worker.execute(); } }); History: Usage before Java 6.0 SwingWorker has been part of Java SE only since Java 6.0. Sun has released versions to be used with earlier JDKs, although they were unofficial versions which were not part of the Java SE and were not mentioned in the standard library documentation. The most recent of these versions dates from 2003 and is often referred to as SwingWorker version 3. Unfortunately, the JDK 6.0 SwingWorker and the Version 3 SwingWorker use different method names and are not compatible. The backport version (see below) is now recommended for pre-Java 6 usage. An example for instantiating SwingWorker 3 is shown below: SwingWorker worker = new SwingWorker() { public Object construct() { ... //add the code for the background thread } public void finished() { ... //code that you add here will run in the UI thread } }; worker.start(); //Start the background thread The start() method executes the code added in the construct() method in a separate thread. To be alerted when the background thread finishes, one need only override the finished() method. The construct() method can return a result which can later be retrieved using SwingWorker's get() method. Backport of the Java 6 SwingWorker A backport of the Java 6 SwingWorker to Java 5 is available at http://swingworker.java.net/. Apart from the package name ( org.jdesktop.swingworker ), it is compatible with the Java 6 SwingWorker. Equivalents System.ComponentModel.BackgroundWorker - .NET Framework flash.system.Worker - Adobe Flash android.os.AsyncTask - Android References External links SwingWorker class documentation for Java 7. Worker Threads and SwingWorker from Oracle's Java Concurrency in Swing tutorial. Improve Application Performance With SwingWorker in Java SE 6 by John O'Conner, January 2007. Java platform Articles with example Java code