Originally posted by swati gupta:
quote:
The yield() method is called to take a thread out of the running state and place it into the runnable pool to allow threads of the same priority to start.
I have come across this line at other palces also.
But even I thing that the yield()method is used to that the low priority threads do not starve.
Indeed, you shouldn't create a thread that sucks up gobs of processing power without giving it up. Doing so it almost bound to make your system unresponsive and painful to use. Rather, if you have a large amount of processing to do, it is wise to invoke the yield method to allow other threads to perform their tasks, as well.
However, which thread actually gets to run is up to the underlying OS.
Java may have intended for yield to allow other threads of the same priority to execute, but that's not up to Java to decide. They can only make a recommendation. The underlying OS has the final decision in the matter.
I hope that helps,
Corey