title: Java thread owns monitor lock but still in Blocked state
body: <p>We are working on a performance issue in our application and we observed the following behavior in the thread dump.</p>
  
  <p>There is a thread which owns the montior lock but still in blocked state.</p>
  
  <pre><code>INT:legacon:41:76" prio=10 tid=0x0000000055df0800 nid=0x2e39 waiting for monitor entry     [0x00002aaacb4d4000]
     java.lang.Thread.State: BLOCKED (on object monitor)
      at com.leg.common.connections.fg.FgConnection.send(FgConnection.java:342)
      - locked &lt;0x00000007345b78c0&gt; (a java.io.BufferedOutputStream)
      at com.leg.mg.core.po.storage.ReplicationConnection.send(ReplicationConnection.java:190)
      at com.leg.mg.core.po.storage.ClusterStorageManager.replicate(ClusterStorageManager.java:620)
      at com.leg.mg.core.po.poEngine.store(poEngine.java:1117)
      at com.leg.mg.core.po.poWorker.storeMessage(poWorker.java:1024)
      at com.leg.mg.proto.RWorker$DocumentMessageSender.run(RouterWorker.java:1976)
      at com.leg.common.threadpool.VirtualThreadGroup$VirtualThreadGroupRunnable.run(VirtualThreadGroup.java:147)
      at com.leg.common.threadpool.ThreadControl.run(ThreadControl.java:201)
      at com.leg.common.threadpool.ThreadPool$PoolThread.run(ThreadPool.java:742)
  </code></pre>
  
  <p>The corresponding code block is</p>
  
  <pre><code>line 250  out = new BufferedOutputStream(socket.getOutputStream(), BUFFER_LENGTH);
  
  line 331  public void send(Object obj, boolean flush) throws ConnectionException {
  .
  .
  line 342   synchronized(out) {
  .         if(!isOpen()) {
  .           throw new ConnectionException("Connection closed", url);
  .         }  
  .
  .         header.reset();
  .         header.write(B_SEND_EX);
  .         header.write((byte)'\r');
  .         header.write((byte)'\n');
  .         int len = splitInt(val.length);
  .         while (len-- &gt; 0) {
  .           header.write(splitBuffer[len]);
  .         }
  .         header.write((byte)'\r');
  .         header.write((byte)'\n');
  .         header.writeTo(out);
  .            out.write(val);
  .        if (flush) {
  .        out.flush();
  .        }
  .          }
  line 364}
  </code></pre>
  
  <p>As per the above stack trace, it owns the montior lock on "out" at line 342. But it is still in BLOCKED state. Aslo, it says waiting for monitor entry [0x00002aaacb4d4000].
  We could not indentify which is that 0x00002aaacb4d4000 and who is owning the lock on it, because there is no other occurrence for 0x00002aaacb4d4000 except this place in the whole thread dump.</p>
  
  <p>How the thread will be in blocking state even after owning monitor lock?</p>
  
  <p>How to identify what is 0x00002aaacb4d4000 ? Will it be any internal java object ?</p>
  
  <pre><code>Java version: jdk1.6.0_32
  </code></pre>
  
  <p>It will be really great if you can help us to understand this case.</p>