package one;
import java.util.Date;
import java.util.*;
public class TestInterrupt {
public static void main(String[] args) {
Thread1 thread = new Thread1();
thread.start();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
thread.interrupt();
System.out.println(thread.isInterrupted());
System.out.println(Thread.interrupted());
System.out.println(thread.isInterrupted());
}
}
class Thread1 extends Thread {
public void run(){
while(!isInterrupted()){
System.out.println(new Date()+" "+isInterrupted());
try {
sleep(1000);
} catch (InterruptedException e) {
return ;
}finally{
//System.out.println(isInterrupted());
}
}
}
}