


Cost of communication between the thread is low.Switching from one process to another requires some time for saving and loading registers, memory maps, updating lists, etc.Ģ) Thread-based Multitasking (Multithreading).Cost of communication between the process is high.In other words, each process allocates a separate memory area. Each process has an address in memory.Thread-based Multitasking (Multithreading)ġ) Process-based Multitasking (Multiprocessing).Process-based Multitasking (Multiprocessing).Multitasking can be achieved in two ways: Multitasking is a process of executing multiple tasks simultaneously. Advantages of Java Multithreadingġ) It doesn't block the user because threads are independent and you can perform multiple operations at the same time.Ģ) You can perform many operations together, so it saves time.ģ) Threads are independent, so it doesn't affect other threads if an exception occurs in a single thread. Java Multithreading is mostly used in games, animation, etc. They don't allocate separate memory area so saves memory, and context-switching between the threads takes less time than process. However, we use multithreading than multiprocessing because threads use a shared memory area. Multiprocessing and multithreading, both are used to achieve multitasking. Multithreading in Java is a process of executing multiple threads simultaneously.Ī thread is a lightweight sub-process, the smallest unit of processing.
