Java Question

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

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?

Answer

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

c.f.

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