A multithreaded program contains two or more parts that can run concurrently. Each part of such program is called a thread and each thread defines a separate path of execution. Therefore multithreading is a specialized form of multitasking.
There are two types of multitasking
- Process based multitasking
- Thread bases multitasking
Difference between Multitasking and Multithreaded
A process is a program that is executing. Process based multitasking is a feature that allows your computer to run two or more program concurrently. For example, you are running java compiler with text editor or visiting a website. In process based multitasking, a program is the smallest unit of code that can be dispatched by the scheduler.
In a thread based multitasking, a thread is the smallest unit of dispatchable code. A single program can perform two or more tasks simultaneously. For example, text editor can format the text at the same time can run spell checker. So process based multitasking is big picture and thread based multitasking deals with details.
Multitasking threads require less overhead than multitasking process. Process are heavy weight tasks which require their own address space. Context switching from one process to other process is costly. Threads on the other hand are light weight. They share the common address space.
Multithreading enables you to write efficient programs that makes maximum processing power.