title: Why use a ReentrantLock if one can use synchronized(this)?
body: <p>I'm trying to understand what makes the lock in concurrency so important if one can use <code>synchronized (this)</code>. In the dummy code below, I can do either:</p>
  
  <ol>
  <li>synchronized the entire method or synchronize the vulnerable area (<code>synchronized(this){...}</code>)</li>
  <li>OR lock the vulnerable code area with a ReentrantLock.</li>
  </ol>
  
  <p>Code:</p>
  
  <pre><code>    private final ReentrantLock lock = new ReentrantLock(); 
      private static List&lt;Integer&gt; ints;
  
      public Integer getResult(String name) { 
          .
          .
          .
          lock.lock();
          try {
              if (ints.size()==3) {
                  ints=null;
                  return -9;
              }   
  
              for (int x=0; x&lt;ints.size(); x++) {
                  System.out.println("["+name+"] "+x+"/"+ints.size()+". values &gt;&gt;&gt;&gt;"+ints.get(x));
              }
  
          } finally {
              lock.unlock();
          } 
          return random;
  }
  </code></pre>