title: Is there a way to wait for the change on an atomic integer
body: <p>Is there a way to wait on an <code>AtomicInteger</code> so that I don't have to keep sleeping my current thread and keep checking on the <code>AtomicInteger</code> like this</p>
  
  <pre><code>while(atomicInt.get() &gt;= 0) {
      Thread.sleep(1000)
  }
  </code></pre>
  
  <p>I know there is such a thing as a <code>CountDownLatch</code> but that only allows me to decrement I also need it to be able to increment</p>
  
  <p>Further BackStory - 
  I have a loop creating threads and I need to wait on one of the threads execution to finish before creating a new thread. I however am using an <code>Executors.newFixedThreadPool(numThreads)</code> and the only way to wait on it seems to be to call the shutdown method await termination and then create a new threadPool so instead I was using an atomic integer to keep track of how many threads were running and/or on the queue so that when that number decreased I could continue with the loop.</p>