java.lang.Objectjava.lang.Throwable
java.lang.Exception
java.lang.InterruptedException
public class InterruptedException
当线程在活动之前或活动期间处于正在等待、休眠或占用状态且该线程被中断时,抛出该异常。有时候,一种方法可能希望测试当前线程是否已被中断,如果已被中断,则立即抛出此异常。下列代码可以达到这种效果:
if (Thread.interrupted()) // Clears interrupted status!
throw new InterruptedException();
Object.wait(),
Object.wait(long),
Object.wait(long, int),
Thread.sleep(long),
Thread.interrupt(),
Thread.interrupted(),
序列化表格
| 构造方法摘要 | |
|---|---|
InterruptedException() 构造不带详细消息的 InterruptedException。 |
|
InterruptedException(String s) 构造带指定详细消息的 InterruptedException。 |
|
| 方法摘要 |
|---|
| 从类 java.lang.Throwable 继承的方法 |
|---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 构造方法详细信息 |
|---|
public InterruptedException()
InterruptedException。
public InterruptedException(String s)
InterruptedException。
s - 详细消息。