鴻蒙OS InterruptedException

2022-05-31 16:51 更新

InterruptedException

java.lang.Object

|---java.lang.Throwable

|---|---java.lang.Exception

|---|---|---java.lang.InterruptedException

public class InterruptedException
extends Exception

當線程等待、休眠或以其他方式被占用,并且線程在活動之前或期間被中斷時拋出。 有時某個方法可能希望測試當前線程是否已被中斷,如果是,則立即拋出此異常。 下面的代碼可以用來實現(xiàn)這個效果:

  if (Thread.interrupted())  // Clears interrupted status!
      throw new InterruptedException();

構(gòu)造函數(shù)摘要

構(gòu)造函數(shù) 描述
InterruptedException() 構(gòu)造一個沒有詳細消息的 InterruptedException。
InterruptedException(String s) 構(gòu)造帶有指定詳細消息的 InterruptedException。

方法總結(jié)

從類 java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
從類 java.lang.Throwable 繼承的方法
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

構(gòu)造函數(shù)詳細信息

InterruptedException

public InterruptedException()

構(gòu)造一個沒有詳細消息的 InterruptedException。

InterruptedException

public InterruptedException(String s)

構(gòu)造帶有指定詳細消息的 InterruptedException。

參數(shù):

參數(shù)名稱 參數(shù)描述
s 詳細信息。
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號