title: What is Atomicity in Java
body: <p>I am studying JAVA concurrency in Practice and found the following definition of Atomic Operation:</p>
  <blockquote>
  <p>Operation A, B are atomic with respect to each other if from the perspective of thread executing A, when another thread executes B, either all of B has executed or none of it has. <strong>An atomic operation is one that is atomic with respect to all operation, including itself, that operates on the same data</strong>.</p>
  </blockquote>
  <p>Lets say I have two thread A &amp; B both accessing AtomicLong variable count.<br />
  Lets say thread A reads count and thread B was busy doing count.incrementAndGe() operation.<br />
  In such a scenario, As per above definition (either all of B has executed or none of it ):</p>
  <p>A) ThreadA see the previous value of count (because count is not yet updated)</p>
  <p>Or</p>
  <p>B) ThreadA will wait until ThreadB completes the operation and see the latest value.</p>
  <p>As per my understanding it should B because otherwise we still could have race condition.</p>