hms-networks / flexy-canary-connector

Apache License 2.0
0 stars 0 forks source link

Investigate the performance of `Thread.yield()` and `Thread.sleep(long)` usage #25

Open alexjhawk opened 1 year ago

alexjhawk commented 1 year ago

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.

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.

Reference: