title: Multi threading lock methods
body: <p>Ex 1)</p>
  
  <pre><code>public void addName(String name) {
      synchronized(this) {
          lastName = name;
          nameCount++;
      }
      nameList.add(name);
  }
  </code></pre>
  
  <p>Ex 2)</p>
  
  <pre><code>public class MsLunch {
      private long c1 = 0;
      private long c2 = 0;
      private Object lock1 = new Object();
      private Object lock2 = new Object();
  
      public void inc1() {
          synchronized(lock1) {
              c1++;
          }
      }
  
      public void inc2() {
          synchronized(lock2) {
              c2++;
          }
      }
  }
  </code></pre>
  
  <p>I got these two java code from java website but I don't clearly see the difference between these two. Could you guys give more explanation which case I should use this interchangeably ? Thanks in advance</p>