"Thread has been interrupted from a waiting state"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I noticed that when calling .Interrupt() & .Join on a sleeping thread, a
ThreadInterruptedException with the message "Thread has been interrupted from
a waiting state." gets thrown.

A few questions about this phenomenon:

(1) What is the technical reason for throwing such an exception? If a thread
is asleep, why shouldn't it be interuptable?

(2) Is there a way to interrupt this thread without this exception? If not,
then where can I catch this exception so that it doesn't propogate up the
stack to an unexpected place?

Note that for my given application resorting to using a shared monitor or
boolean to signal interupption is not an option.

Thanks in advance for your help.
 
Just warp the call that makes the thread Sleep in a Try-Catch that catches
that exception.
 
Back
Top