title: Thread Pool vs Many Individual Threads
body: <p>I'm in the middle of a problem where I am unable decide which solution to take.</p>
  
  <p>The problem is a bit unique. Lets put it this way, i am receiving data from the network continuously (2 to 4 times per second). Now each data belongs to a different, lets say, group.
  Now, lets call these groups, group1, group2 and so on.</p>
  
  <p>Each group has a dedicated job queue where data from the network is filtered and added to its corresponding group for processing.</p>
  
  <p>At first I created a dedicated thread per group which would take data from the job queue, process it and then goes to blocking state (using Linked Blocking Queue).</p>
  
  <p>But my senior suggested that i should use thread pools because this way threads wont get blocked and will be usable by other groups for processing.</p>
  
  <p>But here is the thing, the data im getting is fast enough and the time a thread takes to process it is long enough for the thread to, possibly, not go into blocking mode. And this will also guarantee that data gets processed sequentially (job 1 gets done before job 2), which in pooling, very little chances are, might not happen.</p>
  
  <p>My senior is also bent on the fact that pooling will also save us lots of memory because threads are POOLED (im thinking he really went for the word ;) ). While i dont agree to this because, i personally think, pooled or not each thread gets its own stack memory. Unless there is something in thread pools which i am not aware of.</p>
  
  <p>One last thing, I always thought that pooling helps where jobs appear in a big number for short time. This makes sense because thread spawning would be a performance kill because of the time taken to init a thread is lot more than time spent on doing the job. So pooling helps a lot here.</p>
  
  <p>But in my case group1, group2,...,groupN always remain alive. So if there is data or not they will still be there. So thread spawning is not the issue here.</p>
  
  <p>My senior is not convinced and wants me to go with the pooling solution because its memory footprint is great.</p>
  
  <p>So, which path to take?</p>
  
  <p>Thank you.</p>