What are Threads in Computer Processor or CPU?
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. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.