educative.io

Is multithreaded always faster than single threaded?

“In my run, I see the two threads scenario run within 652 milliseconds whereas the single thread scenario runs in 886 milliseconds . You may observe different numbers but the time taken by two threads would always be less than the time taken by a single thread.” says the authors.
If I have single processor, and if I have no IO operation, I think multithreaded scenario can be slower, because there is an overhead for switching between threads.What do you think?

This sure makes sense. With 2 threads there could be context switching cost and effect of it being higher or lower depends on the task being run in thread