Wednesday, January 13, 2021

What is the difference between process and thread?

A process means that a program is in execution, whereas thread refers to a segment of a process. 

Processes are seen as being not lightweight where threads are considered lightweight - in basic English let's just call them heavy (process) and light (thread)! 

Threads share memory and data with other threads, compared to a process which is mostly isolated. Threads are a bit like social media influencers, always sharing away whenever they can and in the same light-hearted analogy, a process is that 28 year old video gamer living in mum's basement, not communicating very much at all:) 

When we look at a program while it is executing we could see it as being the major activity on your computer - like driving a car where you are fully engaged in operating the mechanisms of the vehicle to accelerate, stop or change gears. In this context a thread is the bit where you are also engaged in checking your mirror, steering and on a straight road operating the radio. 

This brings us to the question of when you use which procedure?

Let's simplify this and think of when we can only perform one action at a time, compared to when we can multi-task. Cooking a meal offers a good example - when you are making a sauce that demands all your attention you can't be side-tracked! However, nothing is preventing you from having a kettle boiling, ready for use; turning on the oven for the next stage of your dish and occasionally stirring another pot on the stove. 

This table below lays out the differences for easy reference:

No comments:

Post a Comment