Will multi-threading increase the speed of the calculation on a single-core processor

c#, multithreading, performance

Solution

In general terms, no it won't speed up anything.

Presumably the same work overall is being done, but now there is the overhead of additional threads and context switches.

On a single processor with HyperThreading (two virtual processors) then the answer becomes "maybe".

Finally, even though there is only one CPU perhaps some of the threads can be pushed to the GPU or other hardware? This is kinda getting away from the "single processor" scenario but could technically be way of achieving a speed increase from multithreading on a single core PC.

Edit: your question now mentions multithreaded apps on a multicore machine. Again, in very general terms, this will provide an overall speed increase to your calculation. However, the increase (or lack thereof) will depend on how parallelizable the algorithm is, the contention for memory and cache, and the skill of the programmer when it comes to writing parallel code without locking or starvation issues.

Problem

On a single-core processor, will multi-threading increase the speed of the calculation? As we all know, multi-threading is used for increasing the user responsiveness and achieved by separating UI threads and calculation threads. But let’s talk about only console applications. Will multi-threading increase the speed of the calculation? Do we get a calculations’ result faster when we calculate through multi-threading. What about on multi cores, will multi-threading increase the speed or not? Edit: I have been asked a question. At any given time, only one thread is allowed to run on a single core. If so, why people use multi-threading in a console application.

Original source

Related problems