title: C3p0 APPARENT DEADLOCK exception
body: <p>I keep getting this exception in my Tomcat log:</p>
  
  <pre><code>com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector run
  WARNING: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@76b28200 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
  com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector run
  WARNING: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@76b28200 -- APPARENT DEADLOCK!!! Complete Status: 
      Managed Threads: 3
      Active Threads: 3
      Active Tasks: 
          com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1201fd18 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
          com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@408f3be4 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
          com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@7ba516d8 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
      Pending Tasks: 
          com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@137efe53
          com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@766b0524
  Pool thread stack traces:
      Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main]
          java.lang.Thread.sleep(Native Method)
          com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)
          com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
      Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main]
          java.lang.Thread.sleep(Native Method)
          com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)
          com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
      Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]
          java.lang.Thread.sleep(Native Method)
          com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)
          com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
  </code></pre>
  
  <p>I am using Hibernate 3.6.2 and C3P0 0.9.1.2 with MySQL. After a couple of hours of searching Google, this APPARENT DEADLOCK exception seems to be usually associated with prepared statement caching. This is my C3P0 configuration in my hibernate.cfg.xml:</p>
  
  <pre><code>&lt;propertyname="connection.provider_class"&gt;org.hibernate.connection.C3P0ConnectionProvider&lt;/property&gt;
  &lt;property name="hibernate.c3p0.acquire_increment"&gt;5&lt;/property&gt;
  &lt;property name="hibernate.c3p0.min_size"&gt;5&lt;/property&gt;
  &lt;property name="hibernate.c3p0.max_size"&gt;60&lt;/property&gt;
  &lt;property name="hibernate.c3p0.idle_test_period"&gt;120&lt;/property&gt;
  &lt;property name="hibernate.c3p0.timeout"&gt;180&lt;/property&gt;              
  &lt;property name="hibernate.c3p0.max_statements"&gt;0&lt;/property&gt;
  </code></pre>
  
  <p>I am not doing any statement caching whatsoever. Any hints of what is wrong here would be greatly appreciated.</p>