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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…