title: Thread.sleep() vs Thread.onSpinWait
body: <p>I have a spin-wait loop that is busy-waiting for a flag to be set. However, it can take <strong>a lot</strong> of time for that to happen - minutes, or even hours.</p>
  
  <p>Would <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Thread.html#sleep-long-" rel="nofollow noreferrer">Thread.sleep()</a> be more efficient than <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Thread.html#onSpinWait--" rel="nofollow noreferrer">Thread.onSpinWait​()</a>?</p>