File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what is happening here Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "what is happening here" Watch "what is happening here" New topic

what is happening here

Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1090
I wanted to see what would happen when an object is blocked and inetrrupt method is called on the thread. I made this program. Now I don't understand why it's behaving the way its behaving. On my PC it simply hangs there for a while and after a few seconds gives an error. Is this program doing the same acts on your computer. Can anyone tell me whats happening and how to tame it. It would be great if I also can get a program that causes a runtime error to occur because interrupt was called and the thread was blocked. But the should be because the thread was blocked and only blocked not waiting and not sleeping. One more thing can I call thread.setPriority() after the call to thread.start().
well here goes my wild code :

[ May 17, 2003: Message edited by: Anupam Sinha ]
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
If the interrupt method is invoked on a thread that is sleeping or waiting then an InterruptedException is thrown. If the thread is not in the not-runnable state, then the thread won't know that it has been interrupted unless it checks the isInterrupted method.

Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="" target="_blank" rel="nofollow">Try my mock exam.</a>
I agree. Here's the link:
subject: what is happening here
It's not a secret anymore!