public class WrongExit extends Thread{
public void run(){
while(!this.isInterrupted()){
System.out.println("Thread is continuing");
long time = System.currentTimeMillis();
while((System.currentTimeMillis()-time<1000)){
}
}
}
public static void main(String[] args){
WrongExit WE = new WrongExit();
System.out.println("----------线程开始---------");
WE.start();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println("********3秒后终止线程********");
Thread.interrupted();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println("线程结束");
}
}