answersLogoWhite
Computer Programming
The Difference Between

What is the difference between process and threads?


Top Answer
User Avatar
Wiki User
Answered 2016-04-16 21:02:48

A process is an instance of a computer program. Each process has its own address space and executes concurrently with other processes. If the system has multiple CPU cores, two or more processes may execute simultaneously.

Every process has at least one thread of execution, the main thread. Any thread within a process can instantiate a new thread of execution within that same process. Every thread shares the same address space as the process itself, however each thread has its own local stack. This makes it possible for two threads to call the same function concurrently. If the system has multiple CPU cores, two or more threads within the same processes may execute simultaneously.

Programmers use multiple thread to divide complex tasks into simpler tasks that can be executed concurrently. As a simple example, suppose we must search an unsorted array of 1 million elements. We could use a single thread and search the entire array from beginning to end but there's a 50/50 chance the element we are looking for resides in the second half of the array which means that we'd need to search through 500,000 elements on average. By dividing the array between two worker threads we should get a result twice as quickly because each thread now only searches an average of 250,000 elements. It therefore follows that the more threads we utilise, the quicker we should get a result, but that's only true up to a point because the number of threads we can physically execute simultaneously depends on the number of CPU cores available. If all threads execute upon the same core then there is no point in multi-threading this particular task. Nevertheless, the task is likely to take some time to complete so it would still be beneficial to delegate the task to at least one worker thread.

For example, if the main thread manages a message queue, the worker thread can post messages to the queue to keep the main thread abreast of its progress. Meanwhile, the user can continue to interact with the process, posting messages to the queue to perhaps initiate another search (in another thread). In this way the main thread's task is reduced to nothing more than processing messages and delegating tasks to worker threads. This is clearly an over-simplification, however it's this type of multi-threading that makes it possible for a graphical user interface to remain responsive to user interactions while time-consuming tasks are being carried out in the background by worker threads.

001
๐ŸŒŽ
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0
User Avatar

User Avatar
Wiki User
Answered 2015-01-30 16:05:14

Every process has at least one thread, the main thread. However threads can spawn new threads. Every thread in a process shares the same virtual memory space but has its own stack. Threads allow a process to perform concurrent tasks.

001
๐ŸŒŽ
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0
User Avatar

Your Answer

Loading...

Still Have Questions?

Related Questions

What is difference process based and thread based multitasking?

-> Difference between process based and thread based multitasking: 1) threads share the same address space where as process doesn't. 2) context switching between threads is usually less expensive than between processes. 3) cost of communication between threads is relatively low.


What is the difference between a computer process and thread in microprocessor?

A thread is a sub process in other words one process can contain multiple threads.


What is the difference between process and thread?

Basically no difference, except that process can use many threads; thread can use only one.


What is difference in operating threads or process threads?

operating thread is nothing but a simple programs or some information is provided in a row where process threads are the which a single sequence stream within a process


What is the difference between a thread and process?

The same metaphor: the difference of a person (thread) and a family (process) A process has at least 1 thread and may have many threads, while 1 thread must live within a process


Difference between child process and threads in operating systems?

One difference is that, when the main program terminates, all its threads are terminated. It is not the case for processes, because they are kind independent of the parent. When the parent terminates, the process keeps going unless the parent waits for it to die.


Whats the difference between plumbing pipe threads and conduit pipe threads?

Plumbing pipe threads are squared and conduit pipe threads are tapered.


Is there any difference between pipe threads PT and national pipe threads NPT?

No n


What is the difference between processes and threads?

The memory space, where a given application is executed is called - process. A Process is the memory set aside for an application to be executed in. Within this process the thing, which is really executed is the thread. The key difference is that processes are fully isolated from each other; threads share (heap) memory with other threads running in the same application. Threads share the address space of the process that created it; processes have their own address. Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process. Threads can directly communicate with other threads of its process; processes must use inter-process communication to communicate with sibling processes. Threads have almost no overhead; processes have considerable overhead. New threads are easily created; new processes require duplication of the parent process. Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes. A great answer to the question can also be found here: (link moved to link section)


What is the difference between pipe threads and electrical conduit pipe threads?

Water pipe threads are tapered, electrical pipe is not tapered.


What is relationship between process and thread?

Process --1------------m-- Threads 1 process to many threads Bring up your Task Manager (if you are using a windows), Performance tap, you can see the number of process and the number of threads, usually the number of threads is a lot higher than the number of processes.


What is the difference between single and double screw threads?

screw thread are single threads which means they are not double


What is the relationship between threads and multiprocessing?

Processes are made of threads; threads within a process can be handled by different processors to improve server performance.


What is the difference between rigid electrical pipe and plumbing pipe?

The threads


What is the difference between capillitial threads and a columella?

Capillitial threads are very minute forms of slime mold. A columella has numerous threads radiating from all sections of the cell.


What is the difference between concurrent and parallel threads?

Its really so easy to distinguish between the concurrent & parallel threads that A parallel thread is the thread maintained the parallel processing system including the process sheduling system is quite murcible. Where as the concurrent threading is the way of manupulation of a thread using simultaneous process threading. It would be be quite better if the book named "Galvin & Siberscartz" book of "Operating System" the chapter process & threads would be followed for maximum details.


What is the difference between pipe threads and bolt threads?

NPT = pipe Briggs standard = Pipe NFT and NFC and ASAE = bolt


What is the difference between element of communication and the communication process?

Explain the difference between the elements of the communication process and the communication process


What is the difference between product metrics and process metrics?

What is a difference between product metrics and process metrics


What is the difference between process skills and tasks skills?

What is the difference between process skills and tasks skills?


What the difference between process piping and power piping?

What the difference between process piping and power piping?


What is the difference between process and thread in net?

A process is a collection of threads that share the same virtual memory. A process has at least one thread of execution, and a thread always run in a process context. Thread is used to allocate and distribute the CPU work scheduling, many programs a re assigned to different threads and they are most of the time independent of each other. Eg: We can open many instance of MS word and MS Excel in our PC, all are monitored and managed by threads. Process is nothing but a program in execution, many threads can run under a process or many thread can combined under the one thread.


What is the difference between a fleece and a cagoule?

A cagoule is more puffy and has threads usually hanging out


What is the difference between an i7 core and a i5 core chip?

i7 has 4 cores 8 threads, i5 has 4 cores 4 threads


What is the difference between technology and process?

what is the difference between license and patent