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