How does wait know about interrupt in Java?
interrupt, java, multithreading
Solution
`wait()` does not poll. `interrupt()` checks the state of the interrupted thread. If it runs, it just sets the flag. If it is in `wait()`, `sleep()`, or `join()`, the interrupting thread also queues it to processor. When interrupted thread resumes execution, it first checks the flag, and throws InterruptedException if the flag was on.
Problem
`Thread.interrupt` interrupts such calls as `sleep`, `join` and `wait`. I wonder how it is exactly implemented. I know `Thread.interrupt` sets a flag `isInterrupted`. Does `wait` just polls this flag ? I hope it does not. So my question is how `wait` "knows" about interrupt.