title: Should I use a different object to lock for each property?
body: <p>I have a class and its properties; the access to these properties is <strong>very frequently</strong> done by different threads.</p>
  
  <p>It is more efficient use the same object (for the lock statement) for each property?</p>
  
  <pre><code>private readonly object padlock = new object();
  
  private string name;
  private int age;
  
  public string Name
  {
     get
     {
        lock(padlock)
           return name;
     }
  
     set
     {
        lock(padlock)
           name = value;
     }
  }
  
  public int Age
  {
     get
     {
        lock(padlock)
           return age;
     }
  
     set
     {
        lock(padlock)
           age = value;
     }
  }
  </code></pre>
  
  <p>Or to use a different object for each property?</p>
  
  <pre><code>private readonly object padlockName = new object();
  private readonly object padlockAge = new object();
  
  private string name;
  private int age;
  
  public string Name
  {
     get
     {
        lock(padlockName)
           return name;
     }
  
     set
     {
        lock(padlockName)
           name = value;
     }
  }
  
  public int Age
  {
     get
     {
        lock(padlockAge)
           return age;
     }
  
     set
     {
        lock(padlockAge)
           age = value;
     }
  }
  </code></pre>
  
  <p>The second version makes any sense?</p>