Multiple threads and performance on a single CPU

后端 未结 6 1995
清酒与你
清酒与你 2020-12-15 07:17

Is here any performance benefit to using multiple threads on a computer with a single CPU that does not having hyperthreading?

6条回答
  •  遥遥无期
    2020-12-15 07:44

    Regardless of the number of CPUs available, if you require preemptive multitasking and/or applications with asynchronous components (i.e. pretty much anything that combines a responsive GUI with a non-trivial amount of computation or continuous I/O processing), multithreading performs much better than the alternative, which is to use multiple processes for each application.

    This is because threads in the same process can exchange data much more efficiently than can multiple processes, because they share the same memory context.

    See this Wikipedia article on computer multitasking for a fairly concise discussion of these issues.

提交回复
热议问题