title: Empty loop which waits for condition (busy-waiting)
body: <p>I have been spending the last 20 minutes doing research on empty loops which purpose are only to wait for a condition to become true.</p>
  
  <p>I have a function called "waitForLoaded" which is a thread created by CreateThread.</p>
  
  <p>The function:</p>
  
  <pre><code>void waitForLoaded(){
      while(!isLoaded){
          Sleep(500); // &lt; my question
      }
      Sleep(500); //sleep another 500ms to ensure everything is loaded.
      //continue on here
  }
  </code></pre>
  
  <p>I am using Sleep(500) to be easy on the CPU as I believe that using either 0 or 1 would drain the processor.</p>
  
  <p>I have seen in many peoples code "Sleep(0)" used and I never understood why not just no sleep at all and to do "while(condition){}.."</p>
  
  <p>I can't find any solid answer on which is more CPU friendly so I am asking people here, what is the difference between busy-waiting with 0ms, 1ms or 500ms and which is more CPU friendly.</p>
  
  <p>In my opinion it would be best to do at least a half sleep which is nearly unnoticeable by the user.</p>