What does the `Thread.interrupt()` method do in Java?
`Thread.interrupt()` forcibly stops the thread from execution immediately, halting all processes.
Thatâ€™s incorrect. `Thread.interrupt()` does not forcibly stop the thread. It merely sets the interrupt flag, and itâ€™s up to the thread to handle it.
Can you explain how a thread can react to an interrupt and how you might use it to safely stop a thread?