public class InterruptDemo {
public static void main(String[] args) {
Thread thread1 = new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(99999);
}
catch(InterruptedException e) {
System.out.println("I'm interrupted!!");
//e.printStackTrace();
}
}
});
thread1.start();
//
///导致InterruptException发生
/
thread1.interrupt(); // interrupt it right now
///
}
}
public static void main(String[] args) {
Thread thread1 = new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(99999);
}
catch(InterruptedException e) {
System.out.println("I'm interrupted!!");
//e.printStackTrace();
}
}
});
thread1.start();
//
///导致InterruptException发生
/
thread1.interrupt(); // interrupt it right now
///
}
}