Benefits of Multithreading
- Programming abstraction: dividing up work and assigning a separate thread to a subtask. Since threads are independent, each thread is aware only of its own job, without getting into the details of other threads’ jobs.
- Parallelism and utilization: with multiple processors, threads can achieve true parallelism, as each thread is an independently schedulable entity.
- Improving responsiveness: one thread might be dedicated to responding to user input, thus always keeping user interaction responsive.
- Blocking doesn’t influence other threads: while one thread could be blocking (waiting for I/O or interrupt handling,) other threads will continue running.
- Faster context switches: the OS only needs to back up the thread’s program counter, stack, and set of registers to memory, but doesn’t need to flush the cache back to memory.
- Memory saving: threads of the same process share the same memory space, unlike several processes, each of which needs allocation of its own memory space.