swingMethod() { // Okay, this is a button callback, we now own the swing thread Thread t=new Thread(new ActuallyDoStuff()); t.start(); } public class ActuallyDoStuff() implements Runnable { public void run() { // this is where you actually do the work } }
public class Worker extends SwingWorker { private List list; public YourClassSwingWorker(List theOriginalList){ list = theOriginalList; } @Override public List doInBackground() { Thread t = new Thread(new ProcessorThread(list)); t.start(); } @Override public void done() { // draw graph on GUI } } class ProcessorThread implements Runnable { //do lots of IO stuff Thread t2 = new Thread(new SecondProcess()); t2.start(); }