Why does Thread.isInterrupted always return false?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
If Thread.isInterrupted() seems to "always" return false, the usual reason is not that interrupts are broken. It is that the interrupt flag was cleared, checked on the wrong thread, or never set in the way you expected. Java interruption is a cooperative signaling mechanism, not a force-stop API.
What isInterrupted() Actually Checks
Each Java thread has an interrupt status flag. Calling interrupt() requests interruption by setting that flag, and isInterrupted() reads it without clearing it.
In this example, the worker sees the flag and exits. That is the simple case.
The Most Common Reason: InterruptedException Cleared the Flag
Many blocking methods such as sleep, wait, and join respond to interruption by throwing InterruptedException. When they do that, the interrupt status is cleared.
That prints false inside the catch block, which surprises many developers. The flag was set, the sleep was interrupted, and then the exception path cleared the status.
If your code catches InterruptedException but still wants higher layers to see the interrupt, restore the status:
That is the standard pattern when you cannot rethrow the checked exception directly.
Do Not Confuse isInterrupted() with interrupted()
This is the second common source of confusion:
- '
isInterrupted()checks a thread’s flag without clearing it' - '
Thread.interrupted()checks the current thread and clears the flag'
Example:
If some code path calls Thread.interrupted() before your later check, the flag may already be gone by the time isInterrupted() runs.
Make Sure You Are Checking the Right Thread
Another easy mistake is interrupting one thread and then checking a different one.
This is wrong:
That asks whether the current thread was interrupted, not whether worker was interrupted.
The correct check is:
Even then, timing matters. The worker may handle the interrupt quickly, clear or restore the flag, and exit before you inspect it from another thread.
Interrupts Are Cooperative, Not Guaranteed Shutdown
Calling interrupt() does not stop the thread by force. It signals the thread that it should stop what it is doing or switch behavior. The target thread must cooperate by:
- checking the flag
- handling
InterruptedException - exiting blocking or looping work cleanly
If the thread ignores interruption, isInterrupted() may briefly become true, but the thread may continue running anyway.
That is why well-behaved worker code usually looks like one of these:
or:
Common Pitfalls
The biggest pitfall is catching InterruptedException and doing nothing. That clears the interrupt signal and makes later checks look like nothing happened.
Another mistake is using Thread.interrupted() when you meant to inspect the flag without clearing it.
Developers also often inspect the wrong thread or inspect too late, after the target thread has already responded to the interrupt.
Finally, do not treat interruption as a guaranteed thread-kill mechanism. It is a cooperative cancellation signal.
Summary
- '
isInterrupted()only reports the current interrupt flag state.' - Blocking methods that throw
InterruptedExceptionusually clear the flag. - '
Thread.interrupted()clears the current thread’s flag, whileisInterrupted()does not.' - Make sure you are checking the correct thread.
- If you catch
InterruptedException, usually re-interrupt or exit cleanly.
Related reading
- Why does throw Error make a function run as synchronous?
- Why does viewModelScope.launch run on the main thread by default
- Why doesn't an async LINQ Select lambda require a return value
- Why doesn't await on Task.WhenAll throw an AggregateException?
- Why doesn't Java allow generic subclasses of Throwable?
- Why doesn't Java allow overriding of static methods?
- Why doesn't await on Task.WhenAll throw an AggregateException?
- Why doesn't 'await' wait for axios request completes?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.