Interview Questions

Describe the difference between a Thread and a Process?

ASP.NET and .NET WEB Questions and Answers

(Continued from previous question...)

Describe the difference between a Thread and a Process?

Thread - is used to execute more than one program at a time.
process - executes single program

A thread is a path of execution that run on CPU, a proccess is a collection of threads that share the same virtual memory. A process have at least one thread of execution, and a thread always run in a process context.

The operating system creates a process for the purpose of running a program. Each process executes a single program. Processes own resources allocated by the operating system. Resources include memory, file handles, sockets, device handles, and windows. Processes do not share address spaces or file resources except through explicit methods such as inheriting file handles or shared memory segments, or mapping the same file in a shared way.
Threads allow a program to do multiple things concurrently. At least one thread exists within each process. If multiple threads can exist within a process, then they share the same memory and file resources.

Thread is a light weight process, which is initialized itself by a process. Light weigt processes does not loads resources required by it itself, these are loaded by its parent process which has generated it.

(Continued on next question...)

Other Interview Questions