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

前端 未结 6 1415
梦毁少年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条回答
  •  遇见更好的自我
    2021-01-31 16:27

    Well, this isn't entirely language agnostic. Some interpreted programming languages don't support real Threads. That is, threads of execution can be defined by the program, but the interpreter is single threaded so all execution is on one core of the CPU.

    For compiled languages and languages that support true multi-threading, a single CPU can have many cores. Actually, most desktop computers now have 2 or 4 cores. So a multi-threaded program executing truely independent tasks can finish 2-4 times faster based on the number of available cores in the CPU.

提交回复
热议问题