bool isFinished = false;
final ProgressDialogue dialogue = new ProgressDialogue("Loading...");
final Thread progressThread = new Thread() {
public void run() {
dialogue.setVisible(true);
}
};
final Thread progressEvent = new Thread() {
public synchronized void run() {
/* DO SOME WORK */
isFinished = true;
}
};
final Runnable doFinished = new Runnable() {
public void run() { saveBackupFile(); }
};
final Thread progressMonitor = new Thread() {
public void run() {
while (true) {
try {
/* SLEEP SOME TIME 1000 ms */
Thread.sleep(1000);
} catch (Exception ex) {
}
/* WAIT FOR WORK FINISHED */
if (isFinished) {
/* FINISH ALL */
Thread.currentThread().interrupt();
break;
}
}
/* CALL DO FINISH METHOD WHEN THIS PROCESS REACH TO END */
SwingUtilities.invokeLater(doFinished);
}
};
progressThread.start();
progressEvent.start();
progressMonitor.start();
final ProgressDialogue dialogue = new ProgressDialogue("Loading...");
final Thread progressThread = new Thread() {
public void run() {
dialogue.setVisible(true);
}
};
final Thread progressEvent = new Thread() {
public synchronized void run() {
/* DO SOME WORK */
isFinished = true;
}
};
final Runnable doFinished = new Runnable() {
public void run() { saveBackupFile(); }
};
final Thread progressMonitor = new Thread() {
public void run() {
while (true) {
try {
/* SLEEP SOME TIME 1000 ms */
Thread.sleep(1000);
} catch (Exception ex) {
}
/* WAIT FOR WORK FINISHED */
if (isFinished) {
/* FINISH ALL */
Thread.currentThread().interrupt();
break;
}
}
/* CALL DO FINISH METHOD WHEN THIS PROCESS REACH TO END */
SwingUtilities.invokeLater(doFinished);
}
};
progressThread.start();
progressEvent.start();
progressMonitor.start();
No comments:
Post a Comment