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;
}
}
}
}
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;
}
}
}
}