代码如下,为什么在中断之后将中断位清除后再进入阻塞,仍然会捕捉到中断异常?
public class InterruptDemo implements Runnable {
public void run() {
try {
//中断当前线程
Thread.currentThread().interrupt();
boolean b = Thread.interrupted();
System.out.println(b); //true
b = Thread.interrupted();
System.out.println(b); //false
//进入阻塞
Thread.currentThread().wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}