OiO.lk Blog java Number of threads for CPU bound tasks in multithreading
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

Exit mobile version