Misunderstanding the difference between single-threading and multi-threading programming

前端 未结 6 1470
梦毁少年i
梦毁少年i 2021-01-31 16:12

I have a misunderstanding of the difference between single-threading and multi-threading programming, so I want an answer to the following question to make everything clear.

6条回答
  •  萌比男神i
    2021-01-31 16:38

    As I understand, only ONE thread will be executed at a time

    That would be the case if the CPU only had one core. Modern CPUs have multiple cores, and can run multiple threads in parallel.

    The program running three threads would run almost three times faster. Even if the tasks are independent, there are still some resources in the computer that has to be shared between the threads, like memory access.

提交回复
热议问题