title: Declaring an object as volatile
body: <p>If you declare a member variable as volatile in Java, does this mean that all the object's data is stored in volatile memory, or that the reference to the object is stored in volatile memory?</p>
  
  <p>For example if I have the following class:</p>
  
  <pre><code>class C{
     int i = 0;
     char c = 'c';
  }
  </code></pre>
  
  <p>If I declare an instance of it as follows:</p>
  
  <pre><code>private volatile C obj;
  </code></pre>
  
  <p>does that store the reference to <code>obj</code> in volatile memory, or <code>obj</code>'s data (<code>obj.i</code> and <code>obj.c</code>) in <code>volatile</code> memory?</p>
  
  <p>Does it make <code>obj.c</code> and <code>obj.i</code> thread safe or not?</p>