假定我有九段程序片分在3个线程中运行,先运行前面三段程序片
3个线程中哪个先结束了运行第四个,再有结束运行第五个,依次直到所有程序片都运行结束. 可以如何实现
同时一个线程中出错,3个同时退出
如何判断监控所有都结束.后再运行其他代码
如何实现?
各位高手请赐教,小弟万分感谢!!!
3个线程中哪个先结束了运行第四个,再有结束运行第五个,依次直到所有程序片都运行结束. 可以如何实现
同时一个线程中出错,3个同时退出
如何判断监控所有都结束.后再运行其他代码
如何实现?
各位高手请赐教,小弟万分感谢!!!
fun2(){}
fun3(){}
.....
fun9(){}runFunction(funIndex) {
switch(funIndex) {
case 1:
fun1();
case 2:
fun2();
case 3:
fun3();
......
default:
break;
}
}
int i=1;
new thread().run(i++);
private final int i = ++Index;
fun() {}
run() {
fun();
}
}
public class Main { funObj arr = new funObj[nCount];
static int Index = 0;
private int increment; static main() {
funObj[Index] = new funObj(){
fun(){
//第1个的代码;
}
};
funObj[Index] = new funObj(){
fun(){
//第2个的代码;
}
};
funObj[Index] = new funObj(){
fun(){
//第3个的代码;
}
};
//............n个;<nCount; thread1 = new MyThread(this,"thread1");
thread2 = new MyThread(this,"thread2");
thread3 = new MyThread(this,"thread3");
thread1,2,3.setDaemon(false);
thread1,2,3.start();
} MyThread extends Thread {
run() {
while(increment<Index){
funObj[increment++].run();
}
}
}
}