简体   繁体   English

什么情况下可能导致独立线程中的InterruptedException?

[英]What situations may cause InterruptedException in independed thread?

In my app I have this simple piece of clock code: 在我的应用程序中,我有以下简单的时钟代码:

while(!clockRunning){
    time++;
    repaint();
    Thread.sleep(1000);
}
}catch (InterruptedException e){}

and I began curious what situation may cause exception above. 我开始好奇什么情况可能导致上述异常。

from the Thread Javadoc : 线程Javadoc

if any thread has interrupted the current thread. 如果有任何线程中断了当前线程。 The interrupted status of the current thread is cleared when this exception is thrown. 引发此异常时,将清除当前线程的中断状态。

basicly when another thread calls this threads interrupt method 基本上,当另一个线程调用此线程的中断方法时

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM