Quoted from RHE:
Note that most schedulters do not stop the yielding thread from running in favor of a thread of lower priority.
Rob
SCJP 1.4
<a href="http://www.rajindery.com" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
Rob
SCJP 1.4
Originally posted by Rob Ross:
True, but then you'll have to implement code to interrupt the thread from an external thread, otherwise it will sleep forever.
<a href="http://www.ajmasters.com" target="_blank" rel="nofollow">http://www.ajmasters.com</a> Real Estate, Tampa Florida
Rob
SCJP 1.4
SCJP2. Please Indent your code using UBB Code
Originally posted by Jose Botella:
Hello Corey
The code using sleep(0) waste time in a loop waiting for a condition to be satisfied. Have you considered using wait and notify for the thread that makes the condition true notifies the waiting thread directly, instead of being "prevented" (at impredictable times) by the check of the sleeping thread?
<a href="http://www.rajindery.com" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
Don't get me started about those stupid light bulbs. |