title: Is a direct assignment of a volatile variable thread safe? As safe as an AtomicReference?
body: <p>Is this as safe as using an AtomicReference?</p>
  
  <pre><code>private volatile String myMember;
  
  public void setMyMember(String s) { 
     myMember = s;
  }
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>private final AtomicReference&lt;String&gt; myMember = new AtomicReference&lt;&gt;();
  
  public void setMyMember(String s) {
      while (true) {
          String current = myMember.get();
          if (myMember.compareAndSet(current, s))
              break;
      }
  }    
  </code></pre>