title: Do concurrent interlocked and reads require a memory barrier or locking?
body: <p>This is a simple problem, but after reading <a href="https://stackoverflow.com/questions/3493931/why-do-i-need-a-memory-barrier">Why do I need a memory barrier?</a> I'm very confused about it.</p>
  
  <p>In the example below, assume different threads are repeatedly calling Increment and Counter:</p>
  
  <pre><code>class Foo{
      int _counter=0;
      public int Counter 
      {
          get { return _counter; }
      }
  
      public void Increment()
      {
          Interlocked.Increment(ref _counter);
      }
  }
  </code></pre>
  
  <p>Sorry if I'm misinterpreting <a href="https://stackoverflow.com/questions/3493931/why-do-i-need-a-memory-barrier">Why do I need a memory barrier?</a> but it seems like it's suggesting the class above might not be providing a <em>freshness guarantee</em> when reading the value of _counter. Could a thread that's repeatedly accessing the Counter property get forever stuck on an old value of Counter (because it is cached in the register)?</p>
  
  <p>Is a memory barrier or a lock before <code>return _counter;</code> necessary?</p>