The performance of Thread.yield() and Thread.sleep(long) should be investigated.
Thread.yield() is intended to signal to the OS that the thread can be suspended and immediately re-added to the ready queue, allowing other threads to run.
The investigation should clarify whether the impact of Thread.yield() can result in indeterminate periods of delay, especially during scenarios where the other running threads may have a high-CPU load.
Thread.sleep(long) is intended to signal to the OS that the thread shall not run before the defined/specified time period has been met/passed. This is expected to be more predictable than Thread.yield() but still allow other threads to execute as necessary while the calling thread sleeps.
The investigation should clarify whether the impact of short Thread.sleep(long) calls can result in the thread not being suspended by the OS, which necessitates the original need to use Thread.yield() to force OS-level rescheduling.
If the sleep interval is increased, does this resolve the issue? Is it a feasible solution?
The performance of
Thread.yield()
andThread.sleep(long)
should be investigated.Thread.yield()
is intended to signal to the OS that the thread can be suspended and immediately re-added to the ready queue, allowing other threads to run.Thread.yield()
can result in indeterminate periods of delay, especially during scenarios where the other running threads may have a high-CPU load.Thread.sleep(long)
is intended to signal to the OS that the thread shall not run before the defined/specified time period has been met/passed. This is expected to be more predictable thanThread.yield()
but still allow other threads to execute as necessary while the calling thread sleeps.Thread.sleep(long)
calls can result in the thread not being suspended by the OS, which necessitates the original need to useThread.yield()
to force OS-level rescheduling.Reference: