This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes interrupt()and priorities Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "interrupt()and priorities" Watch "interrupt()and priorities" New topic
Author

interrupt()and priorities

Henry H
Greenhorn

Joined: Sep 22, 2000
Posts: 5
Will a thread be able to interrupt another thread that has higher priority than itself?
Thanks
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1831

Will a thread be able to interrupt another thread that has higher priority than itself?

Interesting question.
Thread A - Lower priority thread
Thread B - Higher priority thread
This means that the thread A is in a running state and is about to interrupt a thread of higher priority. But if the thread A is running it that means that the thread B is sleeping . It cannot be in a Runnable state as it would be running in this case, as it has higher priority. Thus B wakes up to handel its interrupt exception.
Can you think what happens if thread B is waiting ???
Hope things are clear.

------------------
Regds.
Rahul P. Mahindrakar
mohit joshi
Ranch Hand

Joined: Sep 23, 2000
Posts: 243
My answer would be yes. If thread B is sleeping or waiting then
It would throw InterruptedException. If it is blocking for I/O
then the Interrupted Exception may not be thrown,which is the case with even same priority threads.
If B is running, then A is not. However B may yield and let A run and if A calls interrupt(), then it should set the Interrupted flag of B, thus interrupting B.
I am confused over 2 things. How does Green thread Scheduler work
on windows platform. Does it allows only High priority threads to run and Low priority threads are not run at all, or does it follow round-robin scheduling.I suppose the native threads on windows( which are the threads supplied by OS??)do follow round-robin scheduling.Atleast the Window API threads do.
Secondly, can a thread Create threads which are Higher Priority then itself?My answer would be yes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interrupt()and priorities
 
Similar Threads
join() and completely stopping a thread
threads
help needed plz
Thread Question?
join()?