title: ThreadPoolExecutor configuration
body: <p>I have a situation where I expect adding to the thread pool to be faster than processing. I don't think an unbounded queue will be a good idea because there is enough data that the queue might grow to eat all memory if left unchecked. Given this I'm trying to determine the correct setup for a ThreadPoolExecutor. </p>
  
  <p>My first thought is a fixed thread pool with direct handoff and caller runs failure policy. But I wonder if this will hurt throughput (because every time caller runs policy is invoked the thread pool tasks will likely complete and sit idle for some time).</p>
  
  <p>Another idea is fixed thread pool with ArrayBlockingQueue, but I'm actually not sure of the behavior of that. I'm hoping it means that the Executor prefers creating threads if less than coreThread size, then queues, and if the queue is full it blocks waiting for the queue to get space. But in reading the docs here: </p>
  
  <p><a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html" rel="nofollow">http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html</a></p>
  
  <p>It seems that it will prefer creating threads up to corePoolSize, then add to the queue, and if the queue is full it will try creating threads up to maxThreads (same as coreThreads in this case), and failing that it will run the failure policy.</p>
  
  <p>Can someone clarify the behavior for the case above? And also suggest what the best setup might be for this particular case (one of my suggested ideas or some other one that might work better)?</p>