title: Guarding the initialization of a non-volatile field with a lock?
body: <p>For educational purposes I'm writing a simple version of <code>AtomicLong</code>, where an internal variable is guarded by <code>ReentrantReadWriteLock</code>.
  Here is a simplified example:</p>
  
  <pre><code>public class PlainSimpleAtomicLong {
  
    private long value;
  
    private final ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
  
    public PlainSimpleAtomicLong(long initialValue) {
      this.value = initialValue;
    }
  
    public long get() {
      long result;
  
      rwLock.readLock().lock();
      result = value;
      rwLock.readLock().unlock();
  
      return result;
    }
  
    // incrementAndGet, decrementAndGet, etc. are guarded by rwLock.writeLock()
  }
  </code></pre>
  
  <p><strong>My question</strong>: since "value" is non-volatile, is it possible for other threads to observe incorrect initial value via <code>PlainSimpleAtomicLong.get()</code>?
  E.g. thread <code>T1</code> creates <code>L = new PlainSimpleAtomicLong(42)</code> and shares reference with a thread <code>T2</code>. Is <code>T2</code> guaranteed to observe <code>L.get()</code> as 42?</p>
  
  <p>If not, would wrapping <code>this.value = initialValue;</code> into a write lock/unlock make a difference?</p>