October 22, 2024
Chicago 12, Melborne City, USA
java

Number of threads for CPU bound tasks in multithreading


Assume n is the number of available cores, where n is more than 1 (ie. we have a multi-core processor). I think most places that I read say that we should set the number of threads to be n, if the task is CPU bound, and, of course, parallelisable.

In the case of web applications, should we set it to n-1? My rationale is that we want to have one "reserved"(or main) thread to be undisturbed, and do any required housekeeping stuff. I am not sure if I’m misguided.

(I know there is a more complete treatment of the subject, which takes blocking coefficient into account, but here I am only seeking a rule of thumb.)



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video