Here is what the
Java API Documenation says about the
yield() method
Causes the currently executing thread object to temporarily pause and allow other threads to execute.
This means calling yield()
will stop the thread atleast momentarily. This behaviour is guaranteed.
As you have observed, what happens next depends on lot of things such as how many threads are waiting in the pool, what is the scheduling policy etc, which is out of the scope of the question.
Hence yield() is also a right answer.
Hope this helps,
Ajith
[This message has been edited by Ajith Kallambella (edited August 15, 2000).]