as the title.
public static void main(String[] args) throws InterruptedException {
Thread thread = new Thread(new Runnable() {
@Override
From the Javadoc for Thread.sleep (called by TimeUnit.sleep
):
InterruptedException - if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
I think the intention of isInterrupted()
is to allow you to detect whether a thread has been interrupted before calling something which would throw InterruptedException
. If you've caught InterruptedException
, it's fair to assume that the thread has been interrupted...