title: Design pattern for threadpooling
body: <p>I currently have an application that has a large number of threads and this makes the application very large.  Each thread is long-running, basically an infinite loop of polling for new emails then handling them.  Each thread holds on to one SSL connection, which is why threading works well for the application.</p>
  
  <p>I want to use thread pooling.  The simplest approach is to just fix the number of threads then add say 10 users per thread but even at that point it does not seem to be balancing the work as uniformly as 1 user / thread as each loop is fairly long to process.  Plus this isn't actually a thread pool.</p>
  
  <p>My question is - what is the proper design pattern here (as it's certainly more intelligent than what I wrote above), and is there a C++ library that handles this well?  It would also be helpful to point me to a Java utility as in my experience it's pretty easy to work out a design pattern from a Java utility.</p>