title: Is this example thread safe?
body: <p>Suppose I have singleton class that acts as a data cache.  Multiple threads will read from the cache, and a single thread will periodically refresh it.  It looks something like this:</p>
  
  <pre><code>public sealed class DataStore
  {
      public static DataStore Instance { get { return _instance; } }
      public Dictionary&lt;Foo, Bar&gt; FooBar { get; private set; }
  
      static DataStore() { }
      private DataStore() { }
  
      public void Refresh() {
          FooBar = GetFooBarFromDB();
      }
  
      private static readonly DataStore _instance = new DataStore();
  }
  </code></pre>
  
  <p>My question is essentially, is it safe to <code>Refresh()</code> while other threads may be accessing <code>FooBar</code>?  Do I need to be using locks, or are my getting and setting operations atomic?  Do I need to explicitly declare <code>volatile</code> fields to back up my properties?</p>
  
  <p>P.S., If someone can think of a more descriptive title for this question, I would gladly welcome it.</p>
  
  <p><strong>Edit:</strong> Fixed my example to correct obviously non-atomic code.</p>