What is Thread ?

A thread is a single sequential flow of control within a program.

What is Program ?

A program is set of instruction given to the computer.

Now let us discuss,

A program is running in the machine means a Thread is actually performing the task.

Assume a program is running it is accessing the memory, after it execution another thread will access same memory.
In other words, other program execution is waiting for the thread to complete  its execution.

Right, In real world,

Example 1:
if the bank is having one cashier for deposit, all the depositors has to wait in a queue till there turn comes. I mean 3 person are in queue, 2nd person has to wait till 1st person completes, similarly 3rd person has to wait for 2nd person completes

Example 2:
Lets see now in web world,
Assume exam result websites are single threaded environment,
If one person is accessing a website for result then all other students are in queue !! correct it is not acceptable right ?

With above examples now you will be thinking about Multiple Cashier & Multiple person access for the Website right ?

In the programming world, for these problems there is a concept called MultiThreading !!

Object Oriented Programs comes with multi threading concepts.

Advertisements