title: Wait in Loop until counter is decreased
body: <p>I want to wait in a loop until a counter is decreased. Is this possible? At the moment, I think I need to wait x seconds and check the counter. Then check again. But is there a better solution?</p>
  
  <p>So have a look what I mean:</p>
  
  <pre><code>counter=0;
  for(x=1;x&lt;100;x++){
   if(counter&lt;10){
    counter++;
    dothings
   }else{
    wait until counter&lt;10
    do things
   }
  } 
  function dothings(){
   calculate;
   counter--;
  }
  </code></pre>
  
  <p>So only to show what I mean. </p>