What is the difference between:
//Some code, takes a bit of time to process
(new SomeJFrame()).setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
(new SomeJWindow()).start();//Start a new thread
}
});
And:
class doGraphics extends SwingWorker<Void, Object> {
@Override
public Void doInBackground() {
//Some code, takes a bit of time to process
(new SomeJFrame()).setVisible(true);
return null;
}
@Override
protected void done() {
(new SomeJWindow()).start();//Start a new thread
}
}
(new doGraphics()).execute();
Which method is better to use?