Threads are the virtual components or codes, which divides the physical core of a CPU into virtual multiple cores. A single CPU core can have up-to 2 threads per core.
For example, if a CPU is dual core (i.e., 2 cores) it will have 4 threads. And if a CPU is Octal core (i.e., 8 core) it will have 16 threads and vice-versa.
The thread is created by a process. Every time you open an application, it itself creates a thread which will handle all the tasks of that specific application. Like-wise the more application you open more threads will be created.
The threads are always created by the operating system for performing a task of a specific application.
There is single thread (code of that core which performs the computations also known as primary thread) on the core which when gets the information from the user, creates another thread and allocates the task to it. Similarly, if it gets another instruction it forms second thread and allocates the task to it. Making a total of two threads.
The smartphone application is an example of this, when you open a app it shows a circle which spins continuously, this process is done by a thread created for this purpose only, and the second thread loads the information and presents it in the Graphical User Interface.
The only fact that will limit the creation of the threads will be the number of the threads provided by the physical CPU, and it varies from CPU to CPU. The 1st image is the loading spinner by the first thread and the second one is the GUI loading by the second thread.
Now, What is the use of a thread ?
Threads have become a vital part of the computing as they allow the processor to perform multiple tasks at the same time making the tasks faster. And also making the computer capable of multitasking. Due to threads only you are able to browse the web as well as listen to music simultaneously.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between RISC and CISC processor | Set 2
- Stack Implementation in Operating System uses by Processor
- Multiple-Processor Scheduling in Operating System
- Threads and its types in Operating System
- Producer-Consumer solution using threads in Java
- C++ File Writer-Reader application using Windows Threads
- Differences between Computer Architecture and Computer Organization
- Computer Organization | Performance of Computer
- What happens when we turn on computer?
- Computer Networks | Set 13
- Computer Networks | Set 10
- Computer Networks | Set 9
- Computer Networks | Set 8
- Computer Networks | Set 7
- Computer Networks | Set 6
- Computer Networks | Set 12
- Computer Networks | Set 4
- Computer Networks | Set 3
- Computer Networks | Set 5
- Computer Networks | Set 2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.