WEBVTT

00:06.040 --> 00:09.190
So guys, now let us discuss what are detached threads.

00:09.190 --> 00:13.030
So the detached threads works exactly opposite to Joinable thread.

00:13.300 --> 00:18.850
So let us suppose that you have a multi threaded program and let us call one of the thread of your multi

00:18.850 --> 00:20.920
threaded program as parent thread.

00:20.920 --> 00:21.640
Right.

00:21.670 --> 00:27.190
Now this parent thread decides to create a new child thread at the fork point F, right.

00:27.220 --> 00:34.150
Now this time this child thread is created in the detached mode right after the creation of this new

00:34.150 --> 00:34.900
child thread.

00:34.930 --> 00:39.730
The parent thread resumes its execution along its execution flow.

00:39.730 --> 00:40.420
Right.

00:41.310 --> 00:44.250
And child thread also does the same.

00:44.670 --> 00:48.740
It begins its execution along its own execution flow.

00:48.750 --> 00:49.470
Right?

00:49.950 --> 00:57.690
Now, when the child thread has done its job and when it terminates, then immediately all the resources

00:57.690 --> 01:02.490
of the thread are released by the Kernel's process manager immediately.

01:02.490 --> 01:03.180
Right.

01:03.570 --> 01:10.440
There is absolutely no need for the detached thread to come and join the parent thread at the join point

01:10.860 --> 01:16.560
When the parent thread creates a child thread in the detached mode, there is no need for the parent

01:16.590 --> 01:19.320
thread to invoke p thread join API.

01:19.440 --> 01:20.180
Right.

01:20.190 --> 01:24.540
That is, there is no need for the parent thread to block at the join point.

01:26.180 --> 01:31.370
When the data is thread dominates, they do not join any parent thread.

01:31.400 --> 01:32.900
As simple as that.

01:34.120 --> 01:40.120
So it simply means that resources of the data as thread are released as soon as the thread terminates.

01:40.120 --> 01:47.470
Whereas in case of Joinable thread, the resources of the child thread do not release until the child

01:47.470 --> 01:50.170
Joinable thread joins the parent thread.

01:50.980 --> 01:57.730
A detached thread can be converted into joinable while it is running or vice versa and detached thread

01:57.730 --> 02:00.820
do not return any result to joining thread.

02:00.820 --> 02:01.420
Right.

02:01.450 --> 02:05.770
How can they return the result to the joining thread when they do not join the parent thread?

02:05.770 --> 02:06.310
Right?

02:08.030 --> 02:15.300
So it simply means that data is threads work, They do their job and silently die without telling anybody.

02:15.320 --> 02:15.980
Right.

02:16.010 --> 02:20.430
Whereas Joinable thread notifies the parent thread about its death.

02:20.450 --> 02:21.230
Right.

02:21.940 --> 02:27.400
Now let us create a demo program and see how joinable and detached thread can be created.

02:27.400 --> 02:29.530
And what else can we do?
