私は3〜4スレッドのアプリケーションを持っていますが、2番目のスレッドは1番目のスレッドが終了したときに開始し、3番目は2番目のスレッドが終了したときに開始する必要があります。
//1st thread
new Thread(new Runnable() {
int progressStatus = 0;
public void run() {
progressStatus = dofirstWork();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Update the progress bar
handler.post(new Runnable() {
public void run() {
bar.setProgress(progressStatus);
}
});
}
private int dofirstWork() {
//do some work
return 25;
}
}).start();
//2nd thread
new Thread(new Runnable() {
int progressStatus = 0;
public void run() {
progressStatus = dosecondWork();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Update the progress bar
handler.post(new Runnable() {
public void run() {
bar.setProgress(progressStatus);
}
});
}
private int dosecondWork() {
//do some work
return 50;
}
}).start();
//3rd thread
new Thread(new Runnable() {
int progressStatus = 0;
public void run() {
progressStatus = dothirdWork();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Update the progress bar
handler.post(new Runnable() {
public void run() {
bar.setProgress(progressStatus);
}
});
}
private int dothirdWork() {
//do some work
return 75;
}
}).start();
実際には、最初の関数呼び出しでは25%、2番目の操作では50%でプログレスバーを表示しようとしていますが、.. on .. plz help