title: Need help understanding Tomcat thread pool and JDBC connection pool
body: <p>I have been using Tomcat for a while. But I have never get myself fully educated about how it actually works, especially thread pooling and JDBC connection pooling.</p>
  
  <p>Take a standard Spring web app (with c3p0 connection pool) for example. My questions are</p>
  
  <ol>
  <li><p>When TC starts up, does it create N threads, each with an
  applicationContext? </p></li>
  <li><p>If so, does it mean each thread will have its
  own list of bean instances created? </p></li>
  <li><p>One of the bean definition is</p></li>
  </ol>
  
  <blockquote>
  <pre><code>&lt;bean id="dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"&gt;
    &lt;property name="driverClass" value="${db.driverClassName}"/&gt;
    &lt;property name="jdbcUrl" value="${db.url}"/&gt;
    &lt;property name="user" value="${db.username}"/&gt;
    &lt;property name="password" value="${db.password}"/&gt;
    &lt;property name="minPoolSize" value="5" /&gt;
  &lt;/bean&gt;
  </code></pre>
  </blockquote>
  
  <p>This will create 5 JDBC connections when this bean is created. Does it mean we are gonna end up with</p>
  
  <blockquote>
    <p>5 connections x N threads = 5N connections?</p>
  </blockquote>
  
  <p>This does not sound right to me. I thought the JDBC pool is shared across all threads. But apparently the JDBC pool (defined as a ComboPooledDataSource bean) is created as part of the applicationContext, right? </p>