Should I use volatile if I use synchronized
<p>Should I use <code>volatile</code> every time if I use <code>synchronized</code> dealing with some <code>mutable state</code>.</p>

<ol>
<li><code>synchronized</code> makes me (state/threads) safe</li>
<li><code>volatile</code> makes threads updated about <code>shared mutable state</code>.</li>
</ol>

<p>Then I should put <code>volatile</code> everywhere If I care about threads to be updated?</p>

<p><strong>EDIT: There are two use cases:</strong></p>

<p><strong>1.</strong></p>

<p><strong>1000 threads read and write to this object</strong> (they hope they are updated about state <code>a</code>):</p>

<pre><code> class A {
   private int a;
   public synchronized int getA() {...}
   public void setA(int a) {...}
 }
</code></pre>

<p><strong>2.</strong></p>

<p><strong>There are 1000 threads of ThreadA.</strong> They hope they are updated about state <code>a</code></p>

<pre><code>class ThreadA extends Thread {
 private int a;
 public void run() { synchronized(a) { ... } }
}
</code></pre>
