title: AtomicReferenceFieldUpdater - methods set, get, compareAndSet semantics
body: <p><a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.html" rel="noreferrer">From the Java <code>AtomicReferenceFieldUpdater</code> docs</a>:</p>
  
  <blockquote>
    <p>Note that the guarantees of the <code>compareAndSet</code> method in this class are
    weaker than in other atomic classes. Because this class cannot ensure
    that all uses of the field are appropriate for purposes of atomic
    access, it can guarantee atomicity and volatile semantics only with
    respect to other invocations of <code>compareAndSet</code> and <code>set</code>.</p>
  </blockquote>
  
  <p>This means I can't do normal volatile writes along with <code>compareAndSet</code>, but have to use <code>set</code> instead. It doesn't mention anything about <code>get</code>.</p>
  
  <p>Does that mean that I can still read volatile fields with the same atomicity guarantees - all writes before the <code>set</code> or <code>compareAndSet</code> are visible to everybody who has read the volatile field being?</p>
  
  <p>Or do I have to use <code>get</code> on the <code>AtomicReferenceFieldUpdater</code> instead of volatile reads on the field?</p>
  
  <p>Please post references if you have them.</p>
  
  <p>Thank you.</p>
  
  <p>EDIT:</p>
  
  <p>From <a href="http://jcip.net" rel="noreferrer"><em>Java Concurrency in Practice</em></a>, the only thing they say:</p>
  
  <blockquote>
    <p>The atomicity guarantees for the updater classes are weaker than for
    the regular atomic classes because you cannot guarantee that the
    underlying fields will not be modified directly — the compareAndSet
    and arithmetic methods guarantee atomicity only with respect to other
    threads using the atomic field updater methods.</p>
  </blockquote>
  
  <p>Again, no mention of how the other threads are supposed to read these volatile fields.</p>
  
  <p>Also, am I right to assume that "modified directly" is a regular volatile write?</p>