title: AtomicInteger vs synchronized getters/setters
body: <p>Is this class thread-safe? </p>
  
  <p>Is it possible to see inconsistent values? Lets say initially a's value is 80. Thread 1 calls <code>setA(100)</code> and enters the function but did not yet call <code>a.set(100)</code> and Thread 2 concurrently calls <code>getA()</code>. Is it possible for Thread 2 to see 80?</p>
  
  <pre><code>public class A {
      private AtomicInteger a; 
  
      public int getA() {
          return a.get()
      }
  
      public void setA(int newVal){
          a.set(newVal);
      }   
  }
  </code></pre>
  
  <p>I know that synchronizing it will guarantee thread 2 sees 100, but not sure with AtomicInteger.</p>