Originally posted by Cathy Song:
I thought that Thread.yield caused a thread of same priority to run. Could someone shed some light on this issue?
Thanks.[/QB]
From the SUN tutorial documentation section:
The yield method gives other threads of the same priority a chance to run. If there are no equal priority threads that are runnable, then the yield is ignored.
However, I also found:
Rule of thumb: At any given time, the highest priority thread is running. However, this is not guaranteed. The thread scheduler may choose to run a lower priority thread to avoid starvation. For this reason, use priority only to affect scheduling policy for efficiency purposes. Do not rely on thread priority for algorithm correctness.