ThreadTest求教!!这是为什么啊?

来源:互联网 发布:电商美工设计 编辑:程序博客网 时间:2024/05/01 06:47
import java.util.Date;


public class TheardTest{//为什么结束不了???
public static void main(String[] args) {
Runner2 f=new Runner2();
f.run();
Thread d=new Thread(f);
d.start();
try{
System.out.println("主线程执行");
Thread.sleep(1000);
}catch(InterruptedException es){
d.interrupt();
}
}
}
class Runner2 implements  Runnable{
public void run(){
boolean fig=false;
while(fig){
System.out.println("...."+ new Date()+"....");
try{
Thread.sleep(1000);
}catch(InterruptedException es){
System.out.println("子线程被中断");
return;
}
}
}
}
原创粉丝点击