In java, Multithreading means multiple threads executing simultaneously in a process is called Multithreading.
By definition, multitasking is when multiple processes share common processing resources such as a CPU.
What is thread?
A thread is a sub-process of a process. When a big process is divided into multiple small processes, then that small process is called a thread.
Executing multiple tasks simultaneously is called Multitasking. We use multitasking to utilize the CPU.
There are two types of multitasking.
- Process-based Multitasking
- Thread-based Multitasking
Process-based Multitasking (Multiprocessing)
Executing multiple tasks simultaneously, where each task is a separate independent process is called Process-based multitasking.
Each process has an address in memory. In other words, each process allocates a separate memory area.
While a user typing a java programming in the editor, he can able to listing audio songs by an MP3 player in the system, and at the same time, he can also downloading movies file from the internet. So all these tasks are executing simultaneously and independently of each other.n That why this process is called Process-based Multitasking.
Process-based Multitasking is best suitable at the O.S level.
Thread-based Multitasking (Multithreading)
Executing multiple tasks simultaneously, where each task is a separate independent part of the same program is called Thread-based Multitasking.
Thread-based Multitasking is the best suitable for programming level.
The main objective of Multitasking is to improve performance of the system by reducing response time.
Hope this was helpful for you. If you have any questions please feel free to leave a comment. Thank you for reading.