I'm wondering how multiple thread pools compete for CPU resources in Java? I have multiple thread pools for different tasks. If my CPU has N core and I assign each thread pool with N maximum threads.
- If all the thread pools start their task at the same time, does that means they will compete the CPU resources together?
- How do they compete with each other? Does each thread hold the CPU resource for a period of time? Or does each thread pool hold the CPU resource for a period of time?
The benefit of having different thread pools for different tasks is that the service won't get starved. In the meanwhile, does that mean more thread pools cause more context switching and make the program slower?
In general, is having multiple thread pools a better design than a single thread pool?