Running a tight loop under Windows, Thread.yield() appears to be a no-op--I can observe in the task manager that java is pegging the CPU at close to 100%. This agrees with what I've found by searching--in a preemptive multitasking OS, yield does nothing. Thread.sleep(0) has the same result.
Thread.sleep(1), however, appears to be the way to go--CPU usage by Java stays down.
When, then, would use of yield be preferable--only in a cooperative environment? If one is writing multiplatform code, wouldn't Thread.sleep(1) be the way to go?
Thanks,
Jeff