I have a method that performs two tasks. I would like two threads
to perform each task. Tasks do not share data, they are completely independent.
Before starting the tasks, a dialog
is displayed with the "Wait, processing ..." information.
Here are the codes:
final JDialog dialog = new JDialog(this, true);
SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
// Faz trabalho
return null;
}
@Override
protected void done() {
// Devo fechar Dialog? O outro terminou?
}
};
SwingWorker<Void, Void> worker2 = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
// Faz trabalho
return null;
}
@Override
protected void done() {
//Devo fechar Dialog? O outro terminou?
}
};
worker.execute();
worker2.execute();
dialog.setVisible(true);
// Devo fechar o dialog aqui?
Questions are already commented out in the code.
I would like to close dialog
only when the two threads
are over. How do you know when they are over? Who should close dialog
?