This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread Intrerupt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread Intrerupt" Watch "Thread Intrerupt" New topic
Author

Thread Intrerupt

Santhosh Kumar
Ranch Hand

Joined: Nov 07, 2000
Posts: 242
Hi All, can somebody throw some light on what Thread interrupt is?
Thanks,
Santhosh Kumar.
Bharatesh H Kakamari
Ranch Hand

Joined: Nov 09, 2000
Posts: 198
If a thread wants to interrupt another thread it can call the interrupt() method on the other thread.
For example ThreadA wants to interrupt ThreadB. It calls ThreadB.interrupt(). The compiler before calling interrupt() on ThreadB calls checkAccess() to check whether ThreadA has the access to call this method on B. Threads in the same ThreadGroup can call this method.
mohit joshi
Ranch Hand

Joined: Sep 23, 2000
Posts: 243
The schema is something like this:
When a thread's interrupt method is called,
a) if the thread is sleeping or waiting, it wakes up and the execution moves to catch(InterruptedException) block. If the thread wants, it can return from the run method to end its execution.
b) if the thread is blocking on IO, it may not respond to interrupt call. the workaround for this is that let a separate thread handle the Interrupt call, which should then close the Input/Output stream
c) if the thread is running, then the IsInterrupted (check with documentation) flag is set to true.The thread can check this flag (and end execution if required).
This is as/ my understanding.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread Intrerupt
 
Similar Threads
Thread and Object
Thread & Synchronization
WA #1.....word association
Tech Word Game
subject