1

00:00:00,990  -->  00:00:07,080
High there in the last a mile below that how we can launch a thread and also how we can put the threat

2

00:00:07,170  -->  00:00:08,330
to sleep.

3

00:00:08,520  -->  00:00:09,220
Does them up.

4

00:00:09,240  -->  00:00:13,090
We would also look at a few more amateurs that are related to TRX.

5

00:00:13,200  -->  00:00:19,410
So we look at a bunch of things on one of them as how that trade can get reference to its own object

6

00:00:19,410  -->  00:00:19,650
.

7

00:00:19,650  -->  00:00:24,730
So trade is basically an object we know that and we'll see how that thread can get a reference to its

8

00:00:24,750  -->  00:00:25,890
own object.

9

00:00:25,910  -->  00:00:28,460
I can also see how we can interact.

10

00:00:28,470  -->  00:00:34,660
So if you collect multiple tracks how we can name them and we will also see how we can prioritize that

11

00:00:34,790  -->  00:00:35,000
.

12

00:00:35,070  -->  00:00:41,190
So if you have a bunch of threads maybe you want to get a higher priority to certain threats so that

13

00:00:41,460  -->  00:00:45,990
the shed ular the chip you know we will say what those threats of that higher priority.

14

00:00:45,990  -->  00:00:51,490
So we will look at that and also see why we need to look at something called joint OK.

15

00:00:51,510  -->  00:00:55,320
Jain method which can be invoked on text so that we look at that.

16

00:00:55,320  -->  00:01:01,260
So for example I created this class called last track priority demo as one of the main things that we

17

00:01:01,260  -->  00:01:04,010
are going to look at as priorities.

18

00:01:04,160  -->  00:01:06,510
And it has been added in the concurrency package.

19

00:01:06,550  -->  00:01:08,870
Of just go ahead and look at this.

20

00:01:08,910  -->  00:01:11,260
So here we how the main matter.

21

00:01:11,450  -->  00:01:14,100
And there are all statements here let's talk about them.

22

00:01:14,100  -->  00:01:18,910
The first thing is let's look at how a thread can get access to its own object.

23

00:01:19,010  -->  00:01:19,400
Okay.

24

00:01:19,590  -->  00:01:22,980
So at this statement We are basically in the main thread.

25

00:01:23,130  -->  00:01:23,330
Okay.

26

00:01:23,340  -->  00:01:24,890
So that in itself is a threat.

27

00:01:24,960  -->  00:01:28,430
So here we are invoking thread current thread.

28

00:01:28,830  -->  00:01:32,440
So Dr. Bill Gill reference to Doug to the main thread.

29

00:01:32,540  -->  00:01:33,140
Okay.

30

00:01:33,270  -->  00:01:35,600
So it will give it up to the main thread object.

31

00:01:35,640  -->  00:01:37,690
So let's just go ahead and run it.

32

00:01:38,070  -->  00:01:40,090
So let's not worry about the output.

33

00:01:40,200  -->  00:01:41,850
Let's just look at the statement.

34

00:01:41,850  -->  00:01:44,080
So this is what is getting printed here.

35

00:01:44,380  -->  00:01:47,150
So he's doing credit card and thread Dokdo strength.

36

00:01:47,460  -->  00:01:49,690
So this is just some information here.

37

00:01:49,720  -->  00:01:56,410
So this one is the name of that red market main is done aim of the thread and this is the priority thread

38

00:01:56,460  -->  00:02:00,390
will have a priority and by default it really how it priority off white.

39

00:02:00,780  -->  00:02:05,310
So every thread will get a default part of flight and we look at properties later.

40

00:02:05,470  -->  00:02:06,590
And this last thing.

41

00:02:06,600  -->  00:02:08,840
So there are three entities here.

42

00:02:08,970  -->  00:02:15,600
I mean the priority under threat group but let's not worry about trade group because that group is obsolete

43

00:02:15,600  -->  00:02:15,630
.

44

00:02:15,640  -->  00:02:16,210
No.

45

00:02:16,590  -->  00:02:17,110
OK.

46

00:02:17,190  -->  00:02:18,060
So the right group.

47

00:02:18,060  -->  00:02:22,010
In fact there is an item in active Java is item 73.

48

00:02:22,020  -->  00:02:29,430
It says a white trade groups and trade group is basically an something which is related to security

49

00:02:29,750  -->  00:02:32,050
and it is also related to appliques.

50

00:02:32,070  -->  00:02:37,410
Somehow it did not fulfill its promise and it also has several flaws it seems.

51

00:02:37,410  -->  00:02:40,270
So threat groups is basically obsolete.

52

00:02:40,420  -->  00:02:45,240
And Joshua block and has a heck of a book tells us not to use it.

53

00:02:45,390  -->  00:02:45,850
OK.

54

00:02:46,020  -->  00:02:53,700
So it basically made the names I just tried groups so you can you can group you can logically group

55

00:02:53,820  -->  00:02:57,420
some tracks on perform some activities on them as a group.

56

00:02:57,420  -->  00:02:59,570
So that's some core concept of it.

57

00:02:59,790  -->  00:03:05,500
But if you really need to do something like that there is something called a bull executor's which we'll

58

00:03:05,500  -->  00:03:08,290
will see in the second part of the concurrency chapter.

59

00:03:08,310  -->  00:03:11,570
So if at all you need to do that we can we can use that.

60

00:03:11,640  -->  00:03:12,390
OK.

61

00:03:12,420  -->  00:03:13,480
And we will be doing that.

62

00:03:13,480  -->  00:03:18,260
In fact we will create a group of Thurtell are there so we will look at that later.

63

00:03:18,330  -->  00:03:21,630
But the main thing is we should avoid using correct groups.

64

00:03:21,650  -->  00:03:22,270
OK.

65

00:03:23,100  -->  00:03:24,960
So that's the third group.

66

00:03:24,950  -->  00:03:28,530
And now let's look at here we have two different threats.

67

00:03:28,530  -->  00:03:32,970
We are creating more threats so one is a main threat and we are creating two more threats and we are

68

00:03:32,970  -->  00:03:34,750
setting the name of that threat.

69

00:03:34,770  -->  00:03:40,910
So here this is Beaven which is a threat on D2 and we are also passing the corresponding tasks.

70

00:03:41,000  -->  00:03:43,490
One of them to us is an email campaign.

71

00:03:43,560  -->  00:03:47,470
So this both of these classes implement that honorable interface.

72

00:03:47,880  -->  00:03:53,790
So we will look at that but we are starting the name off the record as email campaign and the name of

73

00:03:53,790  -->  00:03:59,740
the second thread as data aggregator and we can also get their names and we will also look at that.

74

00:04:00,000  -->  00:04:02,560
So why do we want to set names.

75

00:04:02,580  -->  00:04:05,870
So one of the reasons could be the act would be that.

76

00:04:06,090  -->  00:04:13,070
So let's say for example let's take a caller say the caller example let's say there is there are some

77

00:04:13,080  -->  00:04:18,780
Tozan Web sites which we want to run but we only can create hundert tracks.

78

00:04:18,900  -->  00:04:21,830
Let's say our system has certain limitations.

79

00:04:21,840  -->  00:04:26,910
The cause operating system also then place some limits on the number of threats we can create on them

80

00:04:26,920  -->  00:04:27,010
.

81

00:04:27,060  -->  00:04:33,480
So we cannot create more than 100 project or time but we want to crawl around those and sex OK.

82

00:04:33,510  -->  00:04:37,080
Crawling is the process of downloading all of our pages.

83

00:04:37,200  -->  00:04:41,700
And let's say you want to download all the pages and thousand different Web sites every single day.

84

00:04:41,820  -->  00:04:43,470
But we have a hundred correct.

85

00:04:43,620  -->  00:04:46,170
So we will process hundred of search a time.

86

00:04:46,260  -->  00:04:52,500
Now if you want to know which Web sites are being called at a particular instant off line so we can

87

00:04:52,550  -->  00:04:58,820
all this said I mean whenever we are courting a particular Web site we can said Dummy and we can print

88

00:04:58,940  -->  00:05:04,640
the name all the names of all the web search that are being carted at a given instance.

89

00:05:04,830  -->  00:05:10,610
OK so we can print those with a concern so that maybe we'll know that all the active threads and all

90

00:05:10,610  -->  00:05:13,260
the research that are being cut into the garden.

91

00:05:13,610  -->  00:05:17,180
So it's just more of the information for information purpose.

92

00:05:17,330  -->  00:05:18,790
And so that's the second thing.

93

00:05:18,800  -->  00:05:20,870
And we also have to get men now.

94

00:05:20,900  -->  00:05:24,500
The priority here we are saying that set priority here.

95

00:05:24,500  -->  00:05:25,850
There is a different matter.

96

00:05:26,180  -->  00:05:30,680
So 41 we are setting the priority as Max priority on 42.

97

00:05:30,680  -->  00:05:32,940
We are setting it as main priority.

98

00:05:33,280  -->  00:05:33,870
OK.

99

00:05:33,980  -->  00:05:39,440
So basically what is happening is we are trying to influence the should ular and we are seeing that

100

00:05:39,920  -->  00:05:46,550
among the poor wretch trying to give more priority to third line which means that bring it to running

101

00:05:46,550  -->  00:05:51,470
start since both the both of them are and both of them are in an unknowable state.

102

00:05:51,470  -->  00:05:56,120
So by setting this Max priority work on English a juror trying to go higher priority to it.

103

00:05:56,150  -->  00:06:02,030
So that which means that you have to bring it to running state before you'll bring the good running

104

00:06:02,030  -->  00:06:02,520
state.

105

00:06:02,710  -->  00:06:03,220
OK.

106

00:06:03,350  -->  00:06:08,190
So we're just asking for some help but it's all up to Treacher jeweler.

107

00:06:08,330  -->  00:06:12,440
It is very likely that it will lean towards bringing T-1 to running state.

108

00:06:12,590  -->  00:06:13,510
But it's up.

109

00:06:13,550  -->  00:06:15,600
But that is no guarantee that it will do that.

110

00:06:15,700  -->  00:06:16,210
OK.

111

00:06:16,340  -->  00:06:21,220
So it's just there is a higher chance of this to execute before it.

112

00:06:21,430  -->  00:06:27,980
And here we are simply invoking the stock metric and Max underskirt party has a value of can here we

113

00:06:27,980  -->  00:06:28,760
can see it.

114

00:06:28,800  -->  00:06:32,280
Many underskirt party has a value of 1.

115

00:06:32,560  -->  00:06:37,950
And by default if you don't specify anything that is something called not underskirt priority not and

116

00:06:37,960  -->  00:06:39,750
Wadham on that flight.

117

00:06:39,830  -->  00:06:40,820
So that's 34.

118

00:06:41,020  -->  00:06:44,260
And you can set any value that you want between one and then.

119

00:06:44,500  -->  00:06:45,470
OK.

120

00:06:45,980  -->  00:06:50,820
But you have the right we'll give those three constants at least much greater demand Bartie not under

121

00:06:50,830  -->  00:06:51,720
squit property.

122

00:06:52,040  -->  00:06:58,180
So that that's about the stream of debt and we are also having a Penn State rent renting inside Maine

123

00:06:58,190  -->  00:06:58,570
.

124

00:06:59,000  -->  00:07:04,160
And here is the email campaign and here us the data aggregator.

125

00:07:04,160  -->  00:07:10,930
So both of these are to us and both of them have run methods on both of them are simply iterating end

126

00:07:10,950  -->  00:07:17,420
times unpretending the name of that right for instance here we can see that this particular task is

127

00:07:17,720  -->  00:07:19,520
saying thread dog cut and thread.

128

00:07:19,670  -->  00:07:22,920
So which is a feeling and it has been thing done.

129

00:07:22,920  -->  00:07:30,510
Name name of this e-mail company which we have set here here and we are doing the same and we do also

130

00:07:30,910  -->  00:07:33,220
here also did I get to get out also.

131

00:07:33,260  -->  00:07:34,650
So that's what we are doing.

132

00:07:34,670  -->  00:07:40,490
So from that task we are getting the reference to that thread which is running that particular task

133

00:07:40,490  -->  00:07:40,620
.

134

00:07:40,640  -->  00:07:42,470
That's what our contract is doing.

135

00:07:42,580  -->  00:07:42,830
Okay.

136

00:07:42,830  -->  00:07:48,520
So you cannot just simply use this if you use this a grid to be referenced do that the task itself.

137

00:07:48,590  -->  00:07:53,000
But that's not what we want we want a reference to the thread which is running got ask.

138

00:07:53,150  -->  00:07:53,830
OK.

139

00:07:53,900  -->  00:07:54,950
So that's what we are doing.

140

00:07:54,950  -->  00:07:57,470
So here we are giving Max about poverty.

141

00:07:57,550  -->  00:08:02,990
And the reason why we named it as a mail campaign day I get go is because so many companies sometimes

142

00:08:03,020  -->  00:08:09,170
every periodically the companies salt some email companies marketing even campaigns which are very important

143

00:08:09,820  -->  00:08:13,680
and the company might also be aggregating data from different sources.

144

00:08:13,850  -->  00:08:19,570
But certainly email campaigns is a more important task compared to this one.

145

00:08:19,640  -->  00:08:26,510
So email campaigns might be might be sent only once every day or twice a day but when they have to be

146

00:08:26,510  -->  00:08:31,670
done they should be given higher priority because they're business related and it can be done anytime

147

00:08:31,690  -->  00:08:31,760
.

148

00:08:31,790  -->  00:08:33,000
They're not that important.

149

00:08:33,110  -->  00:08:38,610
So they're important but they can be done even during late nights out and auditing offerings.

150

00:08:38,690  -->  00:08:41,220
So you want to give higher priority to that.

151

00:08:41,370  -->  00:08:41,890
OK.

152

00:08:41,900  -->  00:08:45,530
So let's just go ahead and just run it one more time.

153

00:08:45,710  -->  00:08:49,960
So as you can see American business here are given higher priority.

154

00:08:49,980  -->  00:08:54,850
Let me run it one more time.

155

00:08:56,020  -->  00:09:02,700
Now here you can see that diagram gator you can see the switch that happens even though Max about it

156

00:09:02,700  -->  00:09:09,450
he was given an e-mail campaign but still after executing four times did I agree gator the contract

157

00:09:09,530  -->  00:09:11,800
was given in or was brought into running stock.

158

00:09:11,930  -->  00:09:17,120
So there is no real got any but it is very likely that the first you know the one with the higher priority

159

00:09:17,240  -->  00:09:18,320
gets more focus.

160

00:09:18,350  -->  00:09:18,660
OK.

161

00:09:18,680  -->  00:09:21,120
We'll be back and running straight.

162

00:09:22,130  -->  00:09:28,570
OK now here in the e-mail campaign we are saying if I is equal to you then we are saying that our dot

163

00:09:28,580  -->  00:09:34,230
caught and thread dog eat okay and eat is nothing but it's simply a hen.

164

00:09:34,400  -->  00:09:40,300
Should you learn that this particular threat e-mail campaign which is that the one instance that the

165

00:09:40,290  -->  00:09:45,680
thread is willingly eased its current use FCP or whatever reason.

166

00:09:45,680  -->  00:09:51,470
So again it's a hint that there should be order but it's up to the shed uder whether it wants to still

167

00:09:51,560  -->  00:09:56,710
do this or not whether it wants to bring it to and do running state or not.

168

00:09:56,900  -->  00:10:02,600
So both Max priority the priority setting up it is only when they are simply are trivia simply trying

169

00:10:02,600  -->  00:10:05,540
to influence the wretched jeweler but it's up to them.

170

00:10:05,540  -->  00:10:06,370
Richard your honor.

171

00:10:06,550  -->  00:10:06,930
OK.

172

00:10:07,040  -->  00:10:08,860
So that's that you'd better.

173

00:10:08,870  -->  00:10:10,670
I'm finally here.

174

00:10:10,670  -->  00:10:14,870
There's something called Joy in Mankell on this.

175

00:10:15,440  -->  00:10:19,520
So here we are saying that the thread this is the main thread right.

176

00:10:19,520  -->  00:10:20,710
This is the main thread.

177

00:10:20,780  -->  00:10:26,440
It's because it's in the main matter on Main thread is having the statement the dark Jain.

178

00:10:26,510  -->  00:10:32,970
So main thread what it is saying by agreeing this is it is saying I want to suspend myself until it

179

00:10:33,220  -->  00:10:35,000
completes its execution.

180

00:10:35,240  -->  00:10:37,040
OK under Tikal dice.

181

00:10:37,210  -->  00:10:39,190
Flog It For whatever reason.

182

00:10:39,230  -->  00:10:42,470
So there will be instances when you ran a wants to do that.

183

00:10:42,680  -->  00:10:44,390
So it is doing this.

184

00:10:44,390  -->  00:10:49,940
So not to just go ahead and run this and this has to be and Glosa and try catch block with interrupted

185

00:10:49,940  -->  00:10:51,220
exception.

186

00:10:51,220  -->  00:10:52,480
So it does.

187

00:10:52,530  -->  00:10:57,170
So the two is basically the second track which is due to aggregator.

188

00:10:57,650  -->  00:10:59,680
And here it is.

189

00:10:59,840  -->  00:11:06,260
Now you can see that Ymir campaign has it and they like to get it has undone finally inside main has

190

00:11:06,440  -->  00:11:07,580
is getting better.

191

00:11:07,670  -->  00:11:12,830
So when it comes to this particular statement main threat is going to suspend itself.

192

00:11:12,890  -->  00:11:20,270
So this will not get printed but only the truth ratable will exit good and as soon as the contract completes

193

00:11:20,270  -->  00:11:26,690
its execution then main thread will be back in the running straight under which also completes its execution

194

00:11:26,690  -->  00:11:27,370
.

195

00:11:27,370  -->  00:11:31,550
Now there is also another overloaded method here for giant.

196

00:11:31,610  -->  00:11:33,920
So it takes milliseconds.

197

00:11:33,920  -->  00:11:39,890
So if you say run it means that it will very close to one millisecond and within one millisecond if

198

00:11:40,060  -->  00:11:43,440
it does not die then be one word written.

199

00:11:43,460  -->  00:11:44,020
Okay.

200

00:11:44,270  -->  00:11:53,060
So thats what it says here at this rate at most it is milliseconds for distracted by model zero means

201

00:11:53,060  -->  00:11:56,030
to wait for ever selection on this.

202

00:11:56,030  -->  00:11:58,370
Now let's see if it works.

203

00:11:58,490  -->  00:12:05,010
Now as you can see here so email companies their data integrator has kicked in here at this point.

204

00:12:05,030  -->  00:12:10,880
So the main threat has suspended itself but then within one millisecond it could not complete.

205

00:12:10,970  -->  00:12:17,140
So once again you know the main thread is back in action is in running start on expenses inside main

206

00:12:17,570  -->  00:12:22,090
Markovitch that the glue that will complete its execution.

207

00:12:22,160  -->  00:12:23,920
So thats the design method.

208

00:12:24,500  -->  00:12:26,320
So those are the different methods.

209

00:12:26,750  -->  00:12:27,250
Okay.

210

00:12:27,350  -->  00:12:33,330
So we looked at how we can get out of it under the contract on below that set name and get name on really

211

00:12:33,390  -->  00:12:36,300
bad how we can prioritize that.

212

00:12:36,810  -->  00:12:42,320
And we also looked at that joint matter that we can at that console spend itself is ondel second third

213

00:12:42,860  -->  00:12:47,610
underly second grade dies and we also looked at the matter here.

214

00:12:47,920  -->  00:12:48,760
Okay.

215

00:12:48,770  -->  00:12:50,160
So thats about it.

216

00:12:50,310  -->  00:12:53,650
And the guard is once again available in the resources section.

217

00:12:53,690  -->  00:12:55,010
Thank you and happy Cody
