public class InterruptedException
extends 异常
| java.lang.Object | |||
| java.lang.Throwable | |||
| java.lang.Exception | |||
| java.lang.InterruptedException | |||
当一个线程正在等待,睡眠或以其他方式被占用,并且该线程在活动之前或期间中断时抛出。 偶尔一个方法可能希望测试当前线程是否被中断,如果是,立即抛出这个异常。 以下代码可用于实现此效果:
if (Thread.interrupted()) // Clears interrupted status!
throw new InterruptedException();
Public constructors |
|
|---|---|
InterruptedException() 构造一个没有详细信息的 |
|
InterruptedException(String s) 用指定的详细信息构造一个 |
|
继承方法(Inherited methods) |
|
|---|---|
java.lang.Throwable
|
|
java.lang.Object
|
|
InterruptedException ()
构造一个没有详细信息的 InterruptedException 。
InterruptedException (String s)
用指定的详细信息构造一个 InterruptedException 。
| 参数(Parameters) | |
|---|---|
s |
String: the detail message. |