Does calling Thread.interrupt() before a Thread.join() cause the join() to throw an InterruptedException immediately?

concurrency, interrupt, interrupted-exception, java, multithreading

Solution

`interrupt()` interrupts the thread you interrupted, not the thread doing the interrupting.

c.f.

Thread.currentThread().interrupt();
t.join(); // will throw InterruptedException 

Problem

Basically, what the question title says. ``` Thread t = new Thread(someRunnable); t.start(); t.interrupt(); t.join(); //does an InterruptedException get thrown immediately here? ``` From my own tests, it seems to, but just wanted to be sure. I'm guessing `Thread.join()` checks the `interrupted` status of the thread before doing its "wait" routine?

Original source