Java Thread Waiting State and InterruptedException Handling
Which statement is true?
Community Votes
100% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
The core concept tested is the interaction between thread states and interrupts; the common trap is assuming waiting threads consume CPU or transition incorrectly upon timeout.
This question examines the behavior of Java threads in the waiting state, specifically focusing on interrupt handling. It establishes that while waiting, a thread must handle InterruptedException if interrupted.
Candidates often mistakenly believe that waiting threads consume CPU cycles (Option B) or that timeouts lead directly to termination (Option C), ignoring the standard state transitions back to runnable.
Community Discussion (4 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Option D is correct because any thread entering a waiting state via methods likeThread.sleep, Object.wait, or LockSupport.parkNanos can be interrupted by another thread calling interrupt. When this happens, the waiting method throws an InterruptedException, which the thread must either catch and handle or declare in its signature. This is a fundamental contract of Java concurrency.Why the Other Options Are Wrong
Option A is incorrect because moving a thread from waiting to runnable is a normal lifecycle event triggered bynotify, notifyAll, or time expiration; it does not throw an IllegalStateException. Option B is false because threads in the waiting state are inactive and do not consume CPU cycles until they become runnable. Option C is incorrect because when a timed wait expires, the thread moves to the runnable state (to compete for the lock/CPU), not the terminated state, unless the run method completes during that time.Community Comment Notes
The community consensus strongly supports D, with multiple users confirming that waiting threads do not consume CPU and that interrupts result in exceptions. As ASPushkin noted, "A thread is inactive when in the blocked or waiting state... D is correct" regarding exception handling. Comments consistently refute the idea that waiting implies CPU usage or immediate termination.Exam Strategy
Remember that 'Waiting' means the thread is idle until notified or interrupted. Always check if options imply active resource consumption (like CPU) for waiting states—that is usually false. For interrupts, always expect an Exception.
Frequently Asked Questions
Does a thread in waiting state consume CPU?
No. Threads in waiting or blocked states are inactive and yield the CPU to other threads until they become runnable.
Where does a thread go after a timed wait expires?
It moves to the runnable state to contend for the monitor lock or CPU resources, not directly to terminated.