>
> public class VerifyQueryThread implements Runnable{
> public void run(){
> ...
> }
> }
>
> public static void startMutiThread(){
> VerifyQueryThread target = new VerifyQueryThread();
> for(int j = 0; j < 40;j++){
> (new Thread(target)).start();
>
> }
> writeLog();
> }
>
> 我希望writeLog()方法在那40个新开的线程都运行完毕后再执
> ?应该怎么改写代码? 谢谢
改写后的代码如下:
public class VerifyQueryThread implements Runnable{
public void run(){
...
}
}
public static void startMutiThread(){
Thread t[] = new Thread[40];
for(int j = 0; j < t.length;j++){
t[j] = new Thread(new VerifyQueryThread());
t[j].start();
try{
t[j].join();
}catch(InterruptedException e){
....
}
}
writeLog();
}
}