File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes interrupt 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 "interrupt" Watch "interrupt" New topic
Author

interrupt

Vishnu Munnangi
Ranch Hand

Joined: Sep 28, 2004
Posts: 114
HI everyone,
Can anyone explain me what does the interrupt method of the Thread Class do?
Thanks in advance.
Louie van Bommel
Ranch Hand

Joined: Aug 17, 2004
Posts: 76
Here's a link to interrupt in the ranch's faq:
http://www.javaranch.com/certfaq.jsp#q23
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
The API can explain it better than I can:

public void interrupt()

Interrupts this thread.

First the checkAccess method of this thread is invoked, which may cause a SecurityException to be thrown.

If this thread is blocked in an invocation of the wait(), wait(long), or wait(long, int) methods of the Object class, or of the join(), join(long), join(long, int), sleep(long), or sleep(long, int), methods of this class, then its interrupt status will be cleared and it will receive an InterruptedException.

If this thread is blocked in an I/O operation upon an interruptible channel then the channel will be closed, the thread's interrupt status will be set, and the thread will receive a ClosedByInterruptException.

If this thread is blocked in a Selector then the thread's interrupt status will be set and it will return immediately from the selection operation, possibly with a non-zero value, just as if the selector's wakeup method were invoked.

If none of the previous conditions hold then this thread's interrupt status will be set.

Throws:
SecurityException - if the current thread cannot modify this thread



Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interrupt