加入线程
1、示例代码入下:
package com.jh.www;
public class Demo5 {
public static void main(String[] args) {
Thread t1 = new Thread() {
public void run() {
for(int i=0;i<100;i++) {
System.out.println("aaaaaa");
}
}
};
t1.start();
Thread t2 = new Thread() {
public void run() {
for(int i=0;i<50;i++) {
System.out.println("bb");
if(i==10) {
try {
// t1.join();
t1.join(1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
};
t2.start();
}
}