public class MainThread extends Thread {
public void run() {
System.out.println("  mainThread start");

try {
MyThread thread = null;
for (int i = 0; i < 5; i++) {
thread= new MyThread(""+i);
thread.start();
}
// thread.join();
} catch (Exception e) {
e.printStackTrace();
} }
}
这个是主线程public class MyThread extends Thread{
private String name;
public MyThread(String name){
this.name = name;
} public void run(){
for(int i=0; i<100; i++){
System.out.println("    mythread :"+name+":  "+i);
}

}
}
这个是子线程主线程怎么样写才能等待子线程全部执行完再结束主线程?