title: Highly unusual situation - Thread blocked on a lock which it is holding?
body: <p>This java program I am working on seems to hang on startup, so I tried using jconsole to debug the problem.
  As it turns out it is waiting on a call to a method which is declared as -</p>
  
  <pre><code>synchronized void stopQuery()
  </code></pre>
  
  <p>But here is the crazy part, the lock for the 'synchronized' method is already held by the thread which is blocked for it.
  I have attached a screenshot from JConsole after executing the getThreadInfo() MXBean method.<br/><br/>
  Notice that the lockOwnerId and threadId are same! How is this even possible?</p>
  
  <p><a href="https://i.stack.imgur.com/TYWk9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TYWk9.png" alt="alt text"></a>
  </p>
  
  <p>
  <b>Edit:</b> <br/>
   <b><a href="http://placidsystems.com/files/stacktrace.txt" rel="nofollow noreferrer"> Link </a></b> to one of the  stack traces of this situation.
  
  Note that after looking at the stacktrace it might appear that even the 'org.eclipse.jdt.internal.ui.text.JavaReconciler' thread is trying to lock on to the same DiskIndex object, but if you look at the object address you will see that it is in fact a different DiskIndex object.
  
  </p>
  
  <p><b>Edit 2:</b> <br/>
   <b><a href="http://placidsystems.com/files/stacktrace2.txt" rel="nofollow noreferrer">Another Link </a></b> to a different stacktrace I obtained when I reproduced this problem. It should be helpful to compare the two to see what is common.</p>
  
  <p>
  
  </p>