在Java中抛出InterruptedException之后的中断状态

时间:2014-03-03 19:36:06

标签: java multithreading

try{...}
catch(InterruptedException e)
{  }

我想知道在抛出InterruptedException之后会发生什么

是否将线程中断状态设置为true?

1 个答案:

答案 0 :(得分:2)

这取决于什么抛出InterruptedException。但良好的做法,即JDK的方法,就是在抛出异常时清除中断状态。

例如见Object.wait()

  

如果任何线程在当前线程等待通知之前或当前线程中断当前线程。抛出此异常时,将清除当前线程的中断状态。