I am in the middle of a problem when I cannot decide which solution to take.
The problem is a bit unique. Let's look at it this way, I get data from the network continuously (2 to 4 times per second). Now each information belongs to another, say, group. Now let me name these groups, group1, group2, etc.
Each group has a dedicated job queue in which data from the network is filtered and added to the corresponding group for processing.
First, I created a dedicated thread for each group that will receive data from the job queue, process it, and then goes into the blocking state (using the associated blocking queue).
But my elder suggested that I should use thread pools, because this way the threads will not be blocked and will be used by other groups for processing.
But the fact is that getting the im data is fast enough and the time spent by the thread for processing is long enough so that the thread may not go into blocking mode. And it also ensures that the data will be processed sequentially (task 1 will be completed before task 2), which in the pool, there are very few chances, may not happen.
My elder is also inclined to believe that combining will also save us a lot of memory, because the threads are POOLED (they think he really went for the word;)). Although I do not agree with this, because, I personally think, the combined or not every thread gets its own memory stack. If there is not something in the thread pools that I donโt know about.
Last, I always thought that joining helps when jobs appear in large numbers in a short time. This makes sense because a spawning thread will kill performance due to the time taken to create the thread, much more than the time taken to complete the job. So pooling helps a lot here.
But in my case, group1, group2, ..., groupN always stay alive. Therefore, if there is data or not, they will still be there. So spawning threads is not a problem.
My elder is not convinced and wants me to go with a solution pool, because his memory occupies a large place.
So which way to take?
Thanks.