Threads feature image

What are Threads in a CPU?

Threads are always created by the OS to carry out the task of a particular application or software. A thread is created every time you open a software and the thread is responsible to handle all tasks relating to the software. Similarly the more softwares you open the more threads will be created.

There exists a thread called the primary thread, situated on a core, which when receives a command from the user, generates another new thread and assigns it the task it received from the user, likewise, if it receives another command, it generates another new thread and assigns it the latest command it received, equaling the total amount of threads generated to two.

Multi-Threading

MultiThreading is a feature offered by the CPU, which allows multiple threads to execute independent instructions while using the same resources. MultiThreading allows execution of multiple tasks or instructions inside a single process, which helps to increase speed in comparison to previous programming approaches.

Or in other words, MultiThreading is a feature or ability of an operating system to enable multiple users to work on an application without having to make copies of the program (this is how resources, such as CPU time and storage space are saved). MultiThreading is also capable of handling multiple instructions from a single user.

Use of Multi-Threading

The reason for using MultiThreading (while dealing with an application) is to boost the performance of the app. For example it will be used while running a web server, in order, to process multiple continuous requests for data, which allows data for different requests to be fetched simultaneously, rather than fetching data for one request, then another then another, which takes a lot of time, or if you are working on a spreadsheet and you enter data into a cell, the following changes might occur

  • The spreadsheet saves a copy of the data to keep safe in case of unexpected shutdown
  • The width of the cell as well as the column might be altered

In addition, it is much less resource as well as time intensive in comparison to creating processes, which takes much more time and resources than creating threads.

Difference between, Multi –Tasking, Threading and Processing

MultiProcessing

Makes use of multiple CPU’s to boost overall processing and support MultiTasking.

MultiTasking

Is the ability of a computer to execute multiple instructions. MultiTasking is possible because of MultiThreading because it breaks a task into smaller, simpler, executable threads. Every thread has the required programming component to execute said instruction.