I understand that for a CPU-bound task that you typically want 1 thread per core, otherwise you can start adding more threads per core. But what about tasks per thread (or are they one in the same)?
I’m trying to figure out how to chunk up a big problem into the optimal number of Runnables, so that I can submit them to an Executor. My understanding is that you can then configure the number of threads the Executor will use (so its not necessarily 1 to 1).
So my question is: let’s say I find that for my given application I determine that 5 threads per core is the optimal ratio; but how do I determine the optimal number of tasks (Runnables) to create in the first place?
You make it a knob that you can change until you’re happy. What may work for your workstation may not work for the deployment server. It depends. Grab the knob in one hand and a stopwatch in the other, and benchmark it until you’re happy with the results.