hi friends
Describe the difference between a Thread and a Process?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sam HobbsRank #107 · 20.5K reputationPosted Nov 13, 2011, 9:14 AM EST
Note that this question has been asked a few times recently so there are some previous answers that are good. I suggest reading my article An Introduction to Virtual Memory in Windows; it explains about processes also but it does not explain much about threads.
Sam HobbsRank #107 · 20.5K reputationPosted Nov 13, 2011, 7:29 PM EST
You say "caution must be taken so that different threads don't step on each other" and "threads share data structures that should only be modified by one thread at a time", and that is accurate. When we say "can communicate with each other directly" it helps to make it clear that threads usually don't communicate with each other as easily as a thread can communicate with just itself. Yes, it is easier for threads to communicate within a process than across processes, but it is best to use some method to synchronize the communication even with a process.
Also, it might be a little confusing to say that "Threads are easier to create than processes", since in .Net a process can be created by using a single line of code and it usually requires more than one line of code to create a thread. Certainly it is easier for Windows to create a thread than a process, and the most important criteria is that a process requires more of the system's resources than a thread.
It is arguable whether an "application consists of one or more processes". Certainly this depends on what the definition of an application is. If we define an application as a single executable (".exe") file then there is one and only one process for each application, with the exception of domains as I specify above.
Hemant KumarRank #1,202 · 1.5K reputationPosted Nov 13, 2011, 2:05 AM EST
The major difference between threads and processes is 1.Threads share the address space of the process that created it; processes have their own address. 2.Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process. 3.Threads can directly communicate with other threads of its process; processes must use interprocess communication to communicate with sibling processes. 4.Threads have almost no overhead; processes have considerable overhead. 5.New threads are easily created; new processes require duplication of the parent process. 6.Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes. 7.Changes to the main thread (cancellation, priority change, etc.) may affect the behavior of the other threads of the process; changes to the parent process does not affect child processes. http://forums.sureshkumar.net/vb-asp-net-interview-technical-questions/17262-describe-difference-between-thread-process.htmlManoj SevdaRank #1,670 · 916 reputationPosted Nov 13, 2011, 5:48 PM EST
Thread is a coding construct that doesn't affect the architecture of an application. A single process might contains multiple threads; all threads within a process share the same state and same memory space, and can communicate with each other directly, because they share the same variables.
An application consists of one or more processes. A process, in the simplest terms, is an executing program. One or more threads run in the context of the process. A thread is the basic unit to which the operating system allocates processor time. A thread can execute any part of the process code, including parts currently being executed by another thread.
In simple words a process is an executing instance of an application. For example, when you double-click the Microsoft Word icon, you start a process that runs Word. A thread is a path of execution within a process. Also, a process can contain multiple threads. When you start Word, the operating system creates a process and begins executing the primary thread of that process.
a) A process can consist of multiple threads.
b) Processes are independent of each other. Threads, since they share the same address space are interdependent, so caution must be taken so that different threads don't step on each other.
c) Multithreading requires careful programming since threads share data structures that should only be modified by one thread
at a time. Unlike threads, processes don't share the same address space.
d) Threads are easier to create than processes since they don't require a separate address space.
Akshay TeotiaRank #603 · 4K reputationPosted Nov 24, 2011, 11:45 AM EST