C
Christopher Benson-Manica
In general, if a thread's interrupt status has been set, will a call
to a blocking method produce the same behavior as would occur if the
thread were interrupted during the blocking call? The JavaDocs seem
to indicate that this is not true - for example, wait() is documented
to throw an InterruptedException if the thread is interrupted before
or during the call, but Thread.sleep()'s documentation is silent on
what, if anything, occurs if the thread has been interrupted prior to
the call to sleep(). The same also seems to be true of the select()
methods of Selector. Assuming that select() does, in fact, block even
if the current thread's interrupt status is set, is there any
alternative to simply checking Thread.interrupted() prior to calling
select() and taking appropriate action (i.e., throwing an
InterruptedException manually)?
to a blocking method produce the same behavior as would occur if the
thread were interrupted during the blocking call? The JavaDocs seem
to indicate that this is not true - for example, wait() is documented
to throw an InterruptedException if the thread is interrupted before
or during the call, but Thread.sleep()'s documentation is silent on
what, if anything, occurs if the thread has been interrupted prior to
the call to sleep(). The same also seems to be true of the select()
methods of Selector. Assuming that select() does, in fact, block even
if the current thread's interrupt status is set, is there any
alternative to simply checking Thread.interrupted() prior to calling
select() and taking appropriate action (i.e., throwing an
InterruptedException manually)?