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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Nov 14, 2011, 12:29 AM
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.
Sam HobbsPosted Nov 13, 2011, 2:14 PM
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.
Akshay TeotiaPosted Nov 24, 2011, 4:45 PM
Manoj SevdaPosted Nov 13, 2011, 10:48 PM
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.
Hemant KumarPosted Nov 13, 2011, 7:05 AM