"Thread has been interrupted from a waiting state"

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.
 
G

Guest

Just warp the call that makes the thread Sleep in a Try-Catch that catches
that exception.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top