title: Efficiency - use of Thread.yield in loop that waits for variable change
body: <p>I've got some code that looks like the following:</p>
  
  <pre><code>while (this.conditionIsNotYetMet){
      if (timeout()) break;
      // Don't do anything, just wait till the condition is 
      // filled by a different thread or timeout occurs.
  }
  performSomeCode(); // this code relies on the condition having been met
  </code></pre>
  
  <p>The code works - eventually the other thread fills the condition, and the code executes.</p>
  
  <p>I'm curious as to whether or not it would be a good idea to throw in a Thread.yield() - it seems to be correct either way, and at this stage I can't feel a performance difference - but I'm concerned that in the future it might make a difference, e.g. on a different platform.</p>
  
  <p>i.e. code would become</p>
  
  <pre><code>while (this.conditionIsNotYetMet){
      if (timeout()) break;
      Thread.yield(); // &lt;----  CHANGE IS HERE!!!!
      // Don't do anything, just wait till the condition is 
      // filled by a different thread or timeout occurs.
  }
  performSomeCode(); // this code relies on the condition having been met
  </code></pre>
  
  <p>I'm aware that there's probably a much more formal way to achieve this pattern using locks or AsynchronousTasks, but this solution works well at the moment and is clear enough, so why change?</p>