In concurrent programming there are two basic units of execution : processes and threads.
The main point of using concurrent programming is to have the ability of multitasking . Multitasking is a process of executing multiple tasks simultaneously.
Some of benefit of multitasking is to reduces time by doing many things at the time, and to utilize the CPU. Multitasking can be achieved by two ways :
Process Vs Threads
In java we mostly concentrate on threads. However, processes are also important. Her are the basic deference between process and thread:
- Process-based (Multiprocessing) : is the execution of multiple concurrent software processes at any one instance.
- Thread-based (Multithreading ): is the ability to run several part/operations of a program in parallel. So you can subdivide these operations within single application into individual threads.
Process Vs Threads
In java we mostly concentrate on threads. However, processes are also important. Her are the basic deference between process and thread:
- Both Threads and processes run independently: A process runs independently and isolated of other processes, while threads are also called lightweight process which have their own call stack
- Access shared data: process cannot directly access shared data in another process, while threads can.
- Cost of communication is very high between processes while its very low between threads.
- Processes are typically independent, while threads exist as subsets of a process (see below).
No comments:
Post a Comment