Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

5/17/2016 Process 

vs. Thread

Translate: Select Language ▼

  Search

Home
What is the difference between a thread and a process?
Java
 
C/C++
Processes vs Threads
Databases/SQL
A process is an executing instance of an application. What does that mean? Well, for
example, when you double­click the Microsoft Word icon, you start a process that runs Word.
Javascript
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
PHP
primary thread of that process.
Data Structures
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
Design Pattern Questions
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
Excel Interview Questions
‘heavyweight’ tasks – basically the execution of applications.
HTML5
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
Networking
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
Operating Systems
communication – is quite difficult and resource­intensive.
Operating System Interview Questions

How Virtual Memory Works
MultiThreading
Paging and Page Faults Threads, of course, allow for multi­threading. A common example of the advantage of
multithreading is the fact that you can have a word processor that prints a document using a
Purpose of Swapping
background thread, but at the same time another thread is running that accepts user input, so
Thread vs. Process that you can type up a new document.
Swapping Versus Paging
If we were dealing with an application that uses only one thread, then the application would
Vmware Fusion come with Windows? only be able to do one thing at a time – so printing and responding to user input at the same

Does Parallels Desktop come with
time would not be possible in a single threaded application.
Windows?
Each process has it’s own address space, but the threads within the same process share that
Monitors vs Semaphores address space. Threads also share any other resources within that process. This means that it’s
Example of Threading and very easy to share data amongst threads, but it’s also easy for the threads to step on each
Synchronization other, which can lead to bad things.
User Threads vs. System Threads
Multithreaded programs must be carefully programmed to prevent those bad things from
Recursion happening. Sections of code that modify data structures shared by multiple threads are called
critical sections. When a critical section is running in one thread it’s extremely important that no
Apache Interview Questions other thread be allowed into that critical section. This is called synchronization, which we wont
get into any further over here. But, the point is that multithreading requires careful
General/Miscellaneous programming.

Non­Technical Questions Also, context switching between threads is generally less expensive than in processes. And
finally, the overhead (the cost of communication) between threads is very low relative to
Interviewing in India processes.

Here’s a summary of the differences between threads and processes:
Working As a Software Engineer

Financial Analyst Questions

1. Threads are easier to create than processes since they 
Job Advice For Programmers
don't require a separate address space.
           
Puzzles
2. Multithreading requires careful programming since threads 
share data strucures that should only be modified by one thread
Assortment of Knowledge
at a time.  Unlike threads, processes don't share the same 
American Vocabulary address space.
           
Technical Vocabulary 3.  Threads are considered lightweight because they use far 
less resources than processes.
Science Questions            
4.  Processes are independent of each other.  Threads, since they 
share the same address space are interdependent, so caution 
Find a Job must be taken so that different threads don't step on each other.  
This is really another way of stating #2 above.
What: title, keywords            
Where: city, state, or zip 5.  A process can consist of multiple threads.
Find Jobs

Hiring? Job Hun ng? Post a JOB or your RESUME on our JOB BOARD >>

Subscribe to our newsletter for more free interview questions.

http://www.programmerinterview.com/index.php/operating­systems/thread­vs­process/ 1/2
5/17/2016 Process vs. Thread

Follow @programmerintvw

+6   Recommend this on Google

FOLLOW Varoon Sahgal, Author of ProgrammerInterview on

Advertisement

01 Windows Operating System ›

Previous... Next...

3 Comments Programmer Interview 
1  Login

  Recommend  2 ⤤ Share Sort by Best

Join the discussion…
jobs by 

nube101  •  a month ago
good explanation...
△  ▽ • Reply • Share › 

Email
yesMAN  •  4 months ago

Country United States great!


△  ▽ • Reply • Share › 

Asad Moosvi  •  8 months ago
Nice article!
△  ▽ • Reply • Share › 
I'm not a robot

reCAPTCHA ✉ Subscribe d Add Disqus to your site Add Disqus Add


ὑ Privacy
Privacy - Terms

Would you like to thank ProgrammerInterview.com for being a helpful free resource? Then why not tell a friend about us, or simply add a link
to this page from your webpage using the HTML below.

Link to this page: 
<a href="http://www.programmerinterview.com/index.php/operating­systems/thread­vs­process/">Programmer and Software Interview Questions and Answers » Thread vs. Process<

Please bookmark with social media, your votes are noticed and appreciated: Like 23,866 people like this. Sign Up to see what your friends like.

Copyright © 2015 | Programmer Job Board | India Job Board for Programmers |  About Website Designed by NayaPixel.com

http://www.programmerinterview.com/index.php/operating­systems/thread­vs­process/ 2/2

You might also like