Threads in an Operating System: Definition & Examples

An error occurred trying to load this video.

Try refreshing the page, or contact customer support.

Coming up next: Thread State Diagrams, Scheduling & Switches

You're on a roll. Keep up the good work!

Take Quiz Watch Next Lesson
 Replay
Your next lesson will play in 10 seconds
  • 0:00 Threads and Processes
  • 0:53 Differences
  • 1:58 Multi-Threading
  • 3:10 Types of Threads
  • 4:01 Lesson Summary
Save Save Save

Want to watch this again later?

Log in or sign up to add this lesson to a Custom Course.

Log in or Sign up

Timeline
Autoplay
Autoplay
Speed

Recommended Lessons and Courses for You

Lesson Transcript
Instructor: Martin Gibbs

Martin has 16 years experience in Human Resources Information Systems and has a PhD in Information Technology Management. He is an adjunct professor of computer science and computer programming.

In this lesson, you will learn about threads in an operating system and how they work with processes. We will discuss the differences between threads and processes and also understand the concept of multi-threading.

Threads and Processes

In an operating system, a process is a job or a program that can be executed by the computer. Think of MS Word application, which is a process that runs on computer. But an application can do more than one thing at a time, which means that a given process in an operating system can have one or more threads. Threads represent the actual processing of the code.

A process has its own system registers and memory stack which helps them in executing threads. Threads are sometimes called lightweight processes. The graphic below shows a process with a single thread within it:


Single Thread in a Process
Single Thread in a Process


Threads are very helpful in today's multi-tasking world. Considering MS Word application, it is convenient to highlight the misspelled words while you type; or complete auto-saving of your information as you work on it. The threads within the application process help you achieve this goal.

Differences

Processes and thread work together, but they have lots of differences between them. Typically, processes are fairly heavy (like MS Word), while the threads are lighter (like background save option). The table below highlights some of the differences between the two.

Processes Threads
When switching a process, operating system's resources are required No OS resources are required for thread-switching
If a process is blocked, other processes waiting in the queue are also blocked If a thread is blocked, another thread in the same process can still execute
Each process uses same code and has its own memory All threads can share files and share child processes
An application having multiple processes will use more system resources Processes using multiple threads use less system resources
Each process works on its own Threads can access data of other threads

Multi-Threading

It might be easy to confuse multitasking with multi-threading. Multitasking is a general term for doing many tasks at the same time. On the other hand, multi-threading is the ability of a process to execute multiple threads at the same time. Again, the MS Word example is appropriate in multi-threading scenarios. The process can check spelling, auto-save, and read files from the hard-drive, all while you are working on a document.

Consider the following diagram. The threads share the same code, files, and data. This means that two ore more threads can run at the same time (auto-save, grammar check, spell-check, word-count, etc.).


Multiple Threads in a Process
Multiple Threads in a Process


Multi-threading provides greater benefit than single-threading:

To unlock this lesson you must be a Study.com Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use Study.com

Become a Study.com member and start learning now.
Become a Member  Back
What teachers are saying about Study.com
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? Study.com has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account
Support