While studying the source code, I came across the following passage:
#JDK 8, java.util.concurrent.ThreadPoolExecutor 1120:1137 final void runWorker(Worker w) { Thread wt = Thread.currentThread(); Runnable task = w.firstTask; w.firstTask = null; w.unlock(); // allow interrupts boolean completedAbruptly = true; try { while (task != null || (task = getTask()) != null) { w.lock(); // If pool is stopping, ensure thread is interrupted; // if not, ensure thread is not interrupted. This // requires a recheck in second case to deal with // shutdownNow race while clearing interrupt if ((runStateAtLeast(ctl.get(), STOP) || (Thread.interrupted() && runStateAtLeast(ctl.get(), STOP))) && !wt.isInterrupted()) wt.interrupt(); As far as I understand, instead of Thread.interrupted() worth calling wt.interrupted() - just for reasons of code uniformity (the implementation itself would not change it). Am I right, or is this some kind of feature that I overlooked?
upd. in the primary edition - left unchanged above - I made a mistake on my head, the alternative is to call wt.isInterrupted(true)
Thread.interrupted()is a static method. Static methods are not accepted to be called on a class instance. - a_gura