title: What's the difference between a synchronized block and a condition variable lock?
body: <pre><code>...
  lock.lock()
  try{
  ...
  }
  finally{
  lock.unlock()}
  ...
  </code></pre>
  
  <p>I noticed that this doesn't insure absolute mutual exclusion where as synchronized always does, so what are exactly the differences between both? </p>
  
  <pre><code> import java.util.concurrent.locks.Condition;
  import java.util.concurrent.locks.Lock;
  import java.util.concurrent.locks.ReentrantLock;
  
      public class Guys extends Thread{
  
  
  
              public static void go()throws InterruptedException{
  
                  final Lock lock = new ReentrantLock();
  
  
  
                  lock.lock();
                  try{
  
  
  
                  System.out.println("global " + main.global);
  
  
  
                  main.global = main.global + 100;
                  }
                  finally
                  {
  
  
                  lock.unlock();
                  }
  
  
              }
  
  
  
  
  
  
          public void run(){
  
              try{
  
  
  
                  for(int i = 0; i &lt;1; i++)
                  {
                      System.out.println(this);
  
  
  
  
                      go();
  
  
  
                  }
              } catch(InterruptedException e)
              {
                  System.out.println("Interrupted Exception caught");
              }
  
          }
  
  
      }
  </code></pre>
  
  <p>My threads are sharing a single resource. Only synchronized works in this case.</p>