public class MyThread extends Thread{
Object obj = new Object();
public void run(){
synchronized(obj){
try {
obj.wait();
} catch (InterruptedException e) {
System.out.println("throw InterruptedException.");
}
}
System.out.println("end.");
}
}
TESTクラスを実行すると、一時停止状態になっているthインスタンスに対して、interrupt()メソッドを実行したため、wait()メソッドは例外InterruptedExceptionをthrowします。throw InterruptedException. end.