1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
JDialog d = new JDialog(); //qui contient une progress bar
final SwingWorker<Void, Void> s = new SwingWorker<Void, Void>(){
protected Void doInBackground() throws Exception {
Thread t1 = new Thread(new Runnable() {
public void run() {
LANCEMENT D'UN MOTEUR DE CALCUL //qui génére un fichier
}
});
Thread t2 = new Thread(new Runnable() {
public void run() {
boolean fileFound = false;
while(!fileFound) {
try {
fileFound = isFileResultatExist();
Thread.sleep(4000);
} catch (Exception ex) { }
}
}
});
Thread t3 = new Thread(new Runnable() {
public void run() {
CHARGEMENT DES RESULTATS
}
});
t1.start();
t1.join();
t2.start();
t2.join();
t3.start();
t3.join();
return null;
}
protected void done() {
d.dispose(); //JDialog avec une progress bar
}
};
s.execute();
d.setVisible(true); |