There's more...

The Thread class has another method to check whether a thread has been interrupted or not. It's the static method, interrupted(), that checks whether the current thread has been interrupted or not.

There is an important difference between the isInterrupted() and interrupted() methods. The first one doesn't change the value of the interrupted attribute, but the second one sets it to false.

As mentioned earlier, a thread object can ignore its interruption, but this is not the expected behavior.

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.