There’s a lot of work being done behind the scenes to share time on your CPU. The OS and every background app running get time to run code on the CPU, even as your main app runs. If your CPU only has one thread, there has to be work done to check on each application to see if they have code to run.
With multiple threads, you can keep active code running, but if it ever performs a task that needs to wait for something outside of the CPU (like reading stuff off of a hard drive, or downloading a file over network), the second thread can pick up that idle time without a lot of work being done to park the one thread and pick up the new one.
When you start creating multiple threads in an application, you get to have more things being done while others are in those idle cycles. If you don’t have a lot of idle time in your application, then you won’t get much benefit of having more threads than CPU’s.
Latest Answers