public class Join {
/**
加入线程
* @throws
*/
public static void main(String[] args) {
final Thread t1 = new Thread() {
public void run(){
for (int i = 0; i < 5; i++) {
System.out.println(getName() + "...aaa");
}
}
};
Thread t2 = new Thread(){
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println(getName() + "...bbb");
}
}
};
t1.start();
t2.start();
try {
t1.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
|
|