What is optimum thread pool size for simple program running cpu based tasks in Java

If you have CPU bound tasks, as you increase the number of threads you get increasing overhead and slower performances. Note: having more threads than waiting tasks is just a waste of resources, but may not slow down the tasks so much.

I would use a multiple (e.g. 1 or 2) of the number of cpus rather than adding just one as having one too many threads can have a surprising amount of overhead.


For reference, check this description.

http://codeidol.com/java/java-concurrency/Applying-Thread-Pools/Sizing-Thread-Pools/

In short, what you have (No. CPU + 1) is optimal on average.