Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process is a thread or thread is a process?

I was asked this interview question. I replied that thread is the process after thinking that process is a superset of thread but interviewer didn't agree with it. It is confusing and I'm not able to find any clear answer to this.

like image 602
cbinder Avatar asked Sep 11 '26 16:09

cbinder


1 Answers

A process is an executing instance of an application.

A thread is a path of execution within a process. Also, a process can contain multiple threads.

1.

It’s important to note that a thread can do anything a process can do. But since a process can consist of multiple threads, a thread could be considered a ‘lightweight’ process. Thus, the essential difference between a thread and a process is the work that each one is used to accomplish. Threads are used for small tasks, whereas processes are used for more ‘heavyweight’ tasks – basically the execution of applications.

2.

Another difference between a thread and a process is that threads within the same process share the same address space, whereas different processes do not. This allows threads to read from and write to the same data structures and variables, and also facilitates communication between threads. Communication between processes – also known as IPC, or inter-process communication – is quite difficult and resource-intensive.

like image 139
Am_I_Helpful Avatar answered Sep 15 '26 08:09

Am_I_Helpful



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!