美文网首页
Java异常之InterruptedException

Java异常之InterruptedException

作者: KotInstall | 来源:发表于2022-02-08 18:06 被阅读0次

    java.lang.InterruptedException

       Thrown when a thread is waiting, sleeping, or otherwise occupied,and the thread is interrupted,
     either before or during the activity.
       Occasionally a method may wish to test whether the current thread has been interrupted, and if so,
     to immediately throw this  exception.  
       The following code can be used to achieve this effect:
      <pre>
       if (Thread.interrupted())  // Clears interrupted status!
          throw new InterruptedException();
      </pre>
    
    

    相关文章

      网友评论

          本文标题:Java异常之InterruptedException

          本文链接:https://www.haomeiwen.com/subject/cwabkrtx.html