title: is there a 'block until condition becomes true' function in java?
body: <p>I'm writing a listener thread for a server, and at the moment I'm using:</p>
  
  <pre><code>while (true){
      try {
          if (condition){
              //do something
              condition=false;
          }
          sleep(1000);
  
      } catch (InterruptedException ex){
          Logger.getLogger(server.class.getName()).log(Level.SEVERE, null, ex);
      }
  }
  </code></pre>
  
  <p>With the code above, I'm running into issues with the run function eating all the cpu time looping.  The sleep function works, but it seems be a makeshift fix, not a solution.</p>
  
  <p>Is there some function which would block until the variable 'condition' became 'true'?
  Or is continual looping the standard method of waiting until a variable's value changes?</p>