How to determine no. of threads in thread pool ?

How to determine no. of threads in thread pool ?

It depends upon following factors:

  1. CPU cores
  2. CPU bound task
  3. I/O bound tasks

General formula is No. of threads(t) = No. of cores(c) (1+ wait time/CPU time) = No. of cores (1+ blocking co-efficient)

wait time: How much time a thread takes for one task/s I/O operations to complete. blocking coefficient can be 0 to 1

for CPU bound task: t = c * (1+ 0/cpu time) = no. of cores ( since CPU will be utilized fully even with one thread, hence CPU will not be idle, hence no context switching occurs)

for I/O bound task: t = c * (1+ >0)