package thread.threaddemo2;
/**
* join控制线程的执行顺序
* @author JIANGBIN031
*
*/
public class Test {
public static void main(String[] args) {
Thread1 t1 = new Thread1();
Thread2 t2 = new Thread2();
try {
t1.start();
t1.join();
t2.start();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
package thread.threaddemo2;
public class Thread1 extends Thread{
@Override
public void run() {
System.out.println("1...");
System.out.println("2...");
System.out.println("3...");
System.out.println("4...");
System.out.println("5...");
}
}
package thread.threaddemo2;
public class Thread2 extends Thread{
@Override
public void run() {
System.out.println("threada...");
System.out.println("threadb...");
System.out.println("threadc...");
System.out.println("threadd...");
System.out.println("threade...");
}
}