Difference Between Thread and Process

Thread vs Process

Process

In the world of computer programming, a process is an instance or execution of a program. Every process contains a program code and the existing activity. There can be more than one thread that may make up a particular process. Instructions may be executed concurrently. However, it will depend on the operating system being used.

Basically, processes are heavily substantial programs. They consume considerable amounts of memory. Therefore, they are greatly dependent on the resources available for execution. Having said all of these, a process is known to be a “heavyweight process”.

Every process occurs at a different memory location. Therefore, if there are more processes present, the switching between each process is heavily expensive as it will take time from each memory allocation to switch to another allocation. Each process has its own address space which may gobble substantial amounts of supply.

A process is independent of other processes. So, when a parent process is modified it won’t necessarily affect other processes. Because of this behavior, processes require inter-process communication so they can communicate with their siblings.

Furthermore, processes, due to their much more complex nature, are not created with ease. This may require some duplication of processes, typically parent process, to achieve construction.

Thread

Even with minimal system resources, threads are able to be executed simultaneously to attain a specified task. The reason is the fact that a thread is only an execution sequence. It is merely within a process and that is why it is also referred to as a “lightweight process”.

It is considered as the smallest part of a program as it is an independent sequential path of execution within a program. The context switching between threads requires minimal amounts of resource unlike processes. Threads, in essence, share address spaces and they are also easily created.

It should also be mentioned that changes made into the main thread may have an effect on the behavior of the other threads within the same process. Apparently, communication between threads in the same process is direct and seamless.

Summary:

1. A process can contain more than one thread.
2. A process is considered as “heavyweight” while a thread is deemed as “lightweight”.
3. Processes are heavily dependent on system resources available while threads require minimal amounts of resource.
4. Modifying a main thread may affect subsequent threads while changes on a parent process will not necessarily affect child processes.
5. Threads within a process communicate directly while processes do not communicate so easily.
6. Threads are easy to create while processes are not that straightforward.