title: Java Threads Blocked on Logger
body: <p>Our Java (Web) Application runs in JBoss 6x.
  When slowness was reported:</p>
  
  <ol>
  <li>Thread Stack Dump was taken(Details below)</li>
  <li>Memory was examined - Memory usage was found to be very high, almost touching Max Allowed Heap Size, but no Out of Memory.</li>
  </ol>
  
  <p>The Thread Stack Dump shows most threads blocked on Logging with these kind of errors:</p>
  
  <pre><code>waiting for monitor entry [0x000000004b6be000]
     java.lang.Thread.State: BLOCKED (on object monitor)
      at org.jboss.logmanager.handlers.WriterHandler.doPublish(WriterHandler.java:59)
      - waiting to lock &lt;0x00002aaac9a2de68&gt; (a java.lang.Object)
      at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:64)
  </code></pre>
  
  <p>And like this:</p>
  
  <pre><code>   java.lang.Thread.State: BLOCKED (on object monitor)
      at java.io.PrintStream.println(PrintStream.java:756)
  - waiting to lock &lt;0x00002aaac9817a08&gt; (a com.whatever.SomeClass)
  at com.something.ThatClass.thatMethod(ThatClass.java:169)
  </code></pre>
  
  <p>The com.whatever.SomeClass uses org.apache.log4j.Logger<br>
  We use Log4j for logging.</p>
  
  <p>It appears the threads are all blocked on some logging operation.
  This problem has occurred in the past too, and appears to be random, and it slows down/halts the application.</p>
  
  <p>Any ideas?</p>