import java.util.Date;
public class TestJoin {
public static void main(String[] args) {
test3 m=new test3();
Thread n=new Thread(m);
n.start();
for(int i=1;i<=10;i++){
System.out.println(i);
try{
Thread.sleep(1000);
}catch(InterruptedException e){
return;
}
if(i == 5){
try{
n.sleep(5000);
n.join();
}catch(InterruptedException e){
return;
}
}
}
}
}
class test3 implements Runnable{
boolean flag=true;
public void run(){
while(flag){
System.out.println(new Date());
try{
Thread.sleep(1000);
}catch(InterruptedException e){
return;
}
}
}
}
添加回答
举报
0/150
提交
取消