AfterAcademy Tech
•
01 May 2020

While reading this blog, you may be listening to music or doing some other work. In other words, you may be performing different tasks parallelly. In the same way, in a computer for the processes to run in parallel, threads are used. In a computer or mobile game when you see objects like cars, trucks, etc, these are just threads that run in the game application. Consider another example where a web browser may have a thread to display images or videos while other threads to fetch the data from the internet. So, a single application may need to perform several similar tasks parallel. Thread is used to improve the application through parallelism. So, let's get started and learn more about threads.
A thread is an execution unit that has its own program counter, a stack and a set of registers that reside in a process. Threads can’t exist outside any process. Also, each thread belongs to exactly one process. The information like code segment, files, and data segment can be shared by the different threads.
Threads are popularly used to improve the application through parallelism. Actually only one thread is executed at a time by the CPU, but the CPU switches rapidly between the threads to give an illusion that the threads are running parallelly.
Threads are also known as light-weight processes.

The diagram above shows the single-threaded process and the multi-threaded process. A single-threaded process is a process with a single thread. A multi-threaded process is a process with multiple threads. As the diagram clearly shows that the multiple threads in it have its own registers, stack, and counter but they share the code and data segment.
User-Level Thread
Kernel-Level Thread
That’s it for this blog. We will learn more about multi-threading and its models in the next blog. Hope you enjoyed this blog.
Do share this blog with your friends to spread the knowledge. Visit our YouTube channel for more content.
Keep Learning 🙂
Team AfterAcademy!
AfterAcademy Tech
In this blog, we will learn about Process in Operating System and we will also learn about the various states of a Process during its life cycle.

AfterAcademy Tech
In this blog, we will first discuss what is Online Transaction Processing and Online Analytical Processing and then learn the difference among them.

AfterAcademy Tech
In this blog, we will learn the difference between SQL and MySQL. People use these terms intechangeably. But both are having different meanings.

AfterAcademy Tech
In this blog, we will learn what is RDBMS and how it is different from DBMS. People often use these words intechangeably. But there is a difference between these two terms. So, let's learn how.
