title: Do I need to make synchronized getter to make class threadsafe?
body: <p>I've code:</p>
  
  <pre><code>class Counter {
      private int v;
  
      public synchronized int inc() {
          v = v + 1;
          return v;
      }
  
      public int get() {
          return v;
      }
  }
  </code></pre>
  
  <p>What do I need minimum (for performance sake) &amp;&amp; (<strong>please don't use concurrent package as well as other packages other than java.lang</strong> I just wanna study java basics for now) to do</p>
  
  <ol>
  <li>make <code>private volatile int v;</code></li>
  <li>make <code>public int synchronized get() {...</code></li>
  <li>nothing (everything is ok as is)</li>
  </ol>
  
  <p>to make the code above thread safe?</p>
  
  <p>The question 
  <a href="https://stackoverflow.com/questions/11459543/should-getters-and-setters-be-synchronized">Should getters and setters be synchronized?</a>
  doesn't give the answer due to the ambiguity:</p>
  
  <ol>
  <li><blockquote>
    <p>It is a common mistake to assume that synchronization needs to be used
    only when writing to shared variables; this is simply not true.</p>
    
    <p>For each mutable state variable that may be accessed by more than one
    thread, all accesses to that variable must be performed with the same
    lock held. In this case, we say that the variable is guarded by that
    lock.</p>
  </blockquote></li>
  <li><blockquote>
    <p>Normally, you don't have to be so careful with primitives</p>
  </blockquote></li>
  </ol>
  
  <p>So I don't figure from there out the answer in case of primitive int</p>