title: What happens if a thread tries to acquire a lock that it already holds?
body: <p>This is taken from a book written by Joshua Bloch.</p>
  <p>I am not a native English Speaker, hence the reason to ask for clarification of the doubt.</p>
  <blockquote>
  <p>Because intrinsic locks are reentrant, if a thread tries
  to acquire a lock that it already holds, the request
  succeeds. Reentrancy means that locks are acquired on a
  per-thread rather than **per-invocation basis.</p>
  </blockquote>
  <p>By per-invocation basis, does he means on a per method call?
  Consider the snippet:</p>
  <pre><code>class Factoriser {  
      public synchronized void doSomething(){
         // code goes here
      }
  }
  </code></pre>
  <p>Suppose there is a <code>Thread A</code> and is able to acquire a lock on object having the instance method <code>doSomething()</code>. Due to some reason the same thread <code>Thread A</code> again acquires a lock on the same object instance method <code>doSomething()</code>(imagine also that the previous lock has not been released yet).</p>
  <p>If I understand the Joshua's statement correctly, then there will be only a single lock even though there are 2 method call/ invocations. Is my understanding  correct. Please elaborate. The author clarifies this in the below paragraph which further confused me.</p>
  <blockquote>
  <p>Reentrancy is implemented by associating with each lock an acquisition count and an owning thread. When the count is <code>zero</code>, the lock is considered unheld. When a thread acquires a previously unheld lock, the JVM records the owner
  and sets the acquisition count to one. If that same thread
  acquires the lock again, the count is incremented, and
  when the owning thread exits the synchronized block, the
  count is decremented. When the count reaches zero, the lock is released.</p>
  </blockquote>
  <p>If the Reentrancy/locks acquiring is not on a per-invocation basis, why is the count done by JVM set to <code>2</code> for the scenario described above by me?</p>