title: block synchronize with 2 objects is not working
body: <p>I'm testing out a code where I have 2 methods and a statement in each method is synchronized. </p>
  
  <pre><code>private final Object obj1 = new Object();
  private final Object obj2 = new Object();
  
  public void method1(int result)
  {
   //there's a loop to create delay
  
   synchronized (obj1){
     sum = sum + result;
   }
  
   //there's a loop to create delay
  
  }
  
  
  public void method2(int result)
  {
    //there's a loop to create delay
  
   synchronized (obj2){
     sum = sum - result;
   }
  
   //there's a loop to create delay
  
  }
  </code></pre>
  
  <p>What I'm basically doing is I add a result to sum then subtract the same amount then print the sum. So my initial and final amount should be constant.</p>
  
  <p>The problem is I don't know why the final amount is not the same as initial amount when I use 2 diff objects as lock. HOWEVER it's constant when I use 'this' object as lock for both statements. But using 'this' as object didn't make execution time faster than using method synchronized.</p>
  
  <p>I'm still new to synchronization concept so any help is appreciated.</p>