How do you handle thread interruption in Java?

Thread interruption in Java is a cooperative signaling mechanism — calling interrupt() on a thread doesn't forcibly stop it, it just sets a flag (and wakes it if blocked) that well-behaved code is expected to check and respond to by cleaning up and terminating.

Key Points

Example

A worker thread running a loop should check while (!Thread.currentThread().isInterrupted()) { ... } each iteration, and if it calls a blocking method that throws InterruptedException, it should catch it, perform any needed cleanup, and either return or re-interrupt itself before exiting.

public void run() {
    while (!Thread.currentThread().isInterrupted()) {
        try {
            doWork();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt(); // preserve interrupt status
            break;
        }
    }
}

Interview Tip

A concise interview answer is

Interruption is cooperative — calling interrupt() just sets a flag or wakes a blocked thread, it doesn't force it to stop. Code has to check isInterrupted() periodically, or handle InterruptedException from blocking calls, clean up, and either exit or re-set the interrupt flag so the signal isn't silently lost.

Last updated: 16 July 2026

Previous question: What are the differences between Runnable and Callable in Java concurrency?

Next question: How do you check if a Thread holds a lock or not?

More Concurrency and Multithreading interview questions

All Concurrency and Multithreading questions