Single- vs. multi-threaded programming on a single core processor

后端 未结 3 1425
野的像风
野的像风 2021-02-01 07:54

Can someone please explain if there\'s really any advantage to writing a multi-threaded piece of code that runs on a single processor with a single core? E.g., a method that pr

3条回答
  •  深忆病人
    2021-02-01 08:20

    Yes, multi-threading is useful in a single core. If one thread in an application gets blocked waiting for something (say data from the network card or waiting for the disk to write data), the CPU can switch to another thread to keep working.

    BeOS was written with pervasive multithreading in mind, even in a time of single core processors. The result was a very responsive OS, though a rather difficult OS to program for.

提交回复
热议问题