title: Does this usage of check-then-act of an AtomicInteger need to be synchronised?
body: <p>I have this loop that starts worker threads, that decrement an AtomicInteger when they are finished, and I have a check for starting a task when it gets to 0.</p>
  
  <pre><code>private static AtomicInteger dataReadings;
  
  void someMethod() {
      dataReadings = new AtomicInteger(objects.size());
      for (Object object: objects)
              LongAction.perform(object).setResultCallback(new LongActionCallback&lt;Object&gt;() {
                  @Override
                  public void onResult(Object object) {
                      if (dataReadings.decrementAndGet() == 0) {
                          doSomething();
                      }
                  }
              });
          }
  }
  </code></pre>
  
  <p>So my question is should I synchronize the following part of the code:</p>
  
  <pre><code>if (dataReadings.decrementAndGet() == 0) {
      doSomething();
  }
  </code></pre>
  
  <p>and if I should, how? Using a synchronized block? what should I synchronize on?</p>