WEBVTT

00:05.210 --> 00:06.830
So welcome back, guys.

00:06.860 --> 00:12.050
Now, in this section of the course, we will get ourselves familiar with some technical words which

00:12.050 --> 00:13.940
is related to Multi-threading world.

00:15.590 --> 00:18.410
So this section will be a little bit theoretical.

00:18.410 --> 00:24.290
We will going to understand the exact meaning of these words, that is context switching, concurrency

00:24.290 --> 00:25.430
and parallelism.

00:25.430 --> 00:30.920
Because when we will be doing assignments and projects on Multi-threading, then in order to explain

00:30.920 --> 00:34.820
the Multithreading concepts, I would be using these terms too often.

00:35.030 --> 00:38.860
So let us try to understand the meaning of these words in this section.

00:38.870 --> 00:43.160
So to start with, let us understand what exactly concurrency means.

00:43.280 --> 00:50.270
So concurrency simply means that doing two or more different tasks, but the pattern in which you are

00:50.270 --> 00:55.010
doing these tasks determines whether it is a concurrency or not.

00:55.160 --> 01:04.690
So if you do two or more tasks such that you do only one task at a time and you switch between the task.

01:04.700 --> 01:09.240
Now there is a condition that is imposed while you switch between these tasks.

01:09.450 --> 01:15.000
If you switch between the task by preempting the current task that you are doing, then picking up the

01:15.000 --> 01:18.750
next task partially do it and then preempt it again.

01:18.900 --> 01:23.730
Then again picking up the next task, partially do it and then preempt it again.

01:23.730 --> 01:27.090
And you continue to follow the same pattern, right?

01:27.090 --> 01:32.730
And eventually you will end up picking up the first task from the same point where it was left.

01:32.760 --> 01:37.020
Then again, you partially do it and again you preempt it, right?

01:37.020 --> 01:42.660
So you will continue to perform each task in a round robin fashion, preempting the one task, picking

01:42.660 --> 01:44.310
up the next, and so on.

01:45.700 --> 01:52.200
So if you perform two or more tasks in this fashion, then this shows the property of concurrency,

01:52.210 --> 01:52.930
right?

01:54.440 --> 01:59.120
Let us take one real world example which shows the property of concurrency.

01:59.900 --> 02:05.870
So let us suppose that there are three well-diggers that is three persons which has the responsibility

02:05.870 --> 02:11.870
to dig the well, and they are assigned a task to dig their respective 100ft deep.

02:11.870 --> 02:12.440
Well.

02:12.470 --> 02:13.190
Right.

02:13.190 --> 02:18.950
So if there are three well diggers, then each of the well digger has to dig 100ft deep.

02:18.950 --> 02:20.180
Well, right.

02:20.180 --> 02:27.710
So it means that there are three wells to be digged and there is a condition that all three well diggers

02:27.710 --> 02:30.860
have only one well drilling tool.

02:30.860 --> 02:31.520
Right.

02:31.520 --> 02:33.230
Which they have to share.

02:33.380 --> 02:34.180
Right.

02:34.190 --> 02:35.600
So now let us see that.

02:35.600 --> 02:42.710
In what pattern should they dig the well so that the property of concurrency is honored.

02:42.980 --> 02:48.980
So the conditions or constraints that need to be imposed on three well, Digger is that that only one

02:48.980 --> 02:51.050
person can dig a well at a time.

02:51.050 --> 02:57.320
And this is quite obvious because in this example there is only one drilling tool available, right?

02:57.320 --> 03:01.740
So it is quite obvious that only one person can dig a well at a time.

03:02.040 --> 03:09.570
And when current person who is digging the well take rest because he got tired, then the current person

03:09.570 --> 03:15.000
hand over the digging tool to the second person and second person resumed digging his well from the

03:15.000 --> 03:17.250
same point where he left last time.

03:17.430 --> 03:23.250
Similarly, when second person got tired and he wants to take rest, he hand over the digging tool to

03:23.250 --> 03:26.340
the third person and third person resumes again.

03:26.340 --> 03:27.150
Right.

03:27.150 --> 03:33.420
And this process continues until all the three well-diggers complete their respective tasks.

03:33.450 --> 03:38.820
That is all the three well diggers successfully dig their respective 100ft deep.

03:38.820 --> 03:40.170
Well, right.

03:40.380 --> 03:45.350
So you can see that this real world example shows the property of concurrency.

03:45.360 --> 03:51.600
We can conclude that work of all the three well diggers was in progression, right?

03:51.630 --> 03:57.420
Though they were slow because they had to share the same well drilling tool between them.

03:57.420 --> 04:03.240
But at least we can say that the work of all the three well diggers was in progression.

04:03.330 --> 04:04.710
It was not like that.

04:04.710 --> 04:05.190
That one.

04:05.190 --> 04:10.590
Well, Digger had not even started and the rest two were digging the well one by one.

04:10.590 --> 04:11.310
Right.

04:11.850 --> 04:13.890
At any given point of time.

04:13.890 --> 04:19.860
There was some percentage of work completed by each of the three Well-diggers Right.

04:20.040 --> 04:25.710
So two or more tasks which is done in this fashion are concurrent in nature, right?

04:26.010 --> 04:32.610
Later, we will try to map this real world example to the world of Multithreading and see that exact

04:32.610 --> 04:36.300
same pattern is followed by multiple concurrent threads.
