I\'m learning about multithreading, but after reading some tutorials I\'m sort of confused. I don\'t understand how multithreading can speed up an application.
By in
In some cases, multi threading slows down the application because locking and context switching requires some cpu resource, but overall application performance would greatly improve when you target multi core or multi cpu machine, because the only way to distribute your code across cores/cpus is to use threads.
In single core machines, running a single task with multiple threads will surely cause slow down due to the fact mentioned above.
Another usage of threads is to keep ui responsive, imagine a scenario when you need to perform a heavy I/O operations, such as reading from a device, fetching data from network etc. if you perform those operations in main thread, your ui will be blocked while I/O operation is running. You can avoid ui blocking by running I/O operations in different thread. Probably, that was meant with "speeding up the application".