Does it make sense to spawn more than one thread per processor?

前端 未结 9 1232
面向向阳花
面向向阳花 2020-12-10 16:15

From a logical point of view an application may need dozens or hundreds of threads, some of which will we sleeping most of the time, but a very few will be always running co

9条回答
  •  春和景丽
    2020-12-10 16:44

    Short answer is "yes".

    Even thought you could gain more from multithreading on a multiprocessor environement, it's still a useful technology on a single processor machine, mainly because it means you'll delegate some work to the process scheduler, who should have much better information than you have.

    If you don't multithread, you'll end up doing the scheduling job yourself, which could be a good thing if that's what you need, but will most probably be both tedious and inefficient

提交回复
热议问题