package com.qianfeng.join;
public class TestJoin {
static Thread th2 = null;
public static void main(String[] args) {
Thread th1 = new Thread(new Runnable() {
@Override
public void run() {
try {
th2.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
for(int i=0;i<10;i++){
System.out.println(Thread.currentThread().getName()+"---"+i);
}
}
});
th2 = new Thread(new Runnable() {
@Override
public void run() {
// try {
// th1.join();
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
for(int i=0;i<10;i++){
System.out.println(Thread.currentThread().getName()+"---"+i);
}
}
});
th1.start();
th2.start();
}
}