title: Property with Volatile or Lock
body: <p>I have a property with a backing field which I want to make thread safe (get and set).
  The get and set method has no logic except the setting and returning.</p>
  
  <p>I think there are two ways to capsule the logic in the property self (volatile and lock).
  Is my understanding of the two's correct or have I make any mistakes?</p>
  
  <p>Below are my examples:</p>
  
  <pre><code>    public class ThreadSafeClass
      {
          // 1. Volatile Example:
  
          private volatile int _processState_1;
          public int ProcessState_1
          {
              get { return _processState_1; }
              set { _processState_1 = value; }
          }
  
          // 2. Locking Example:
  
          private readonly object _processState_2Lock = new object();
          private int _processState_2;
          public int ProcessState_2
          {
              get
              {
                  lock (_processState_2Lock)
                  {
                      return _processState_2;
                  }
              }
              set
              {
                  lock (_processState_2Lock)
                  {
                      _processState_2 = value;
                  }
              }
          }
      }
  </code></pre>