Hi there this is they don't want to let go and they'll come back. 2
Finally it's time to learn about competency which is nothing but multithread. 3
You may recall from our first two lessons of the course taught about what Djala is an audience of Jawa 4
did one of the goals were the languages on earth that is James Gosling on his team who wants to build 5
a language that would support Mark dickered. 6
So that was one off there goes on so Djala supported Magdi turning under just one of the core attributes 7
of giallo. 8
So this is one of the fundamental lessons and of course multithreading is nothing but multiple activities 9
at the same time and we see that all the time in our daily lives. 10
For instance in our smartphones as we are using a smartphone we also see certain things getting updated 11
in the background. 12
For instance apps like Facebook and Skype do get updated all the time as we are using the home. 13
And another example is a web browser where we see the pages and bit into the pages. 14
We have the regular content and we also have the images and the images keep getting downloaded concurrently 15
as we are viewing the rampageous. 16
That's especially useful when the network is very slow. 17
OK in some places the network is not really fast and it is very useful in such cases. 18
So as you're viewing the content the images will get downloaded in the background. 19
Similarly we also have web sites serving advertisements. 20
So we have the content regular content and also the advertisements in the site and those advertisements 21
are coming from the partners of the Web site and those partners are queried concurrently in order to 22
solve the X.. 23
And that example is something called the dollars which search engines like Google use on crawlers basically 24
don't know the pages and they download lots and lots of tens of thousands of pages concurrently. 25
Later in the course we will look at a few programs that will actually monitored this. 26
That is just getting downloaded and it concurrently on among other applications. 27
There is also something called federated search where the user Square-D is dispatched to multiple sources 28
concurrently and the response that those sources Cedartown is munged on the fly and shown to the user 29
they are generally referred to as metasearch engines are Nuzzi a lot of them and the Clavell domain 30
that a single site queries might to put Travis X.. 31
So those are some of the applications of concurrency on multithreaded programming is definitely much 32
more complex than non multi-threaded programming. 33
So lets look at motivation to see why you might be threading is needed in the first place. 34
So far we learned about sequent shell programming where the program has executed one step at a time 35
. 36
And most problems can be solved using just sequential programming. 37
However certain tasks like read operations ending put out put my block on do data is available like 38
we have seen that with the read operations and input output unblocking has other tasks. 39
Does wasting time. 40
So for instance if you are running a page and sticking lot time then the subsequent task has to hard 41
on you or Shippey you is actually waiting on your current task. 42
So you are wasting the time. 43
The solution is concurrent programming which will allow you to continue execution even if that task 44
is blocked. 45
Let's actually look at this example. 46
Here we have the trillion system. 47
Let's consider that we are searching for the Book of Job Searching from these three different sources 48
. 49
One is the actual data is on the other two are Lipscombe This is from Goodrich and Google Books and 50
we can also see that time involved in getting a response from each of the sources now sequence your 51
programming here required us SBI. 52
You want to just search from the database on it will pick it on 10 milliseconds and once that is done 53
we create a good read. 54
We're just taking it all for seconds. 55
So you were wait for 4 seconds and once you get the response from good reads you would then query Google 56
Books which gives the response in two seconds. 57
So in total it is taking at around 6 seconds. 58
Now with concurrent programming which we are calling a C.P. here you may also query the database first 59
and get back the result in 10 milliseconds. 60
Then you would query good reads but this time as it does taking time to get a response your concurrent 61
program would in the meanwhile create a Google Books which would give that response back in 2 seconds 62
and then within another two seconds. 63
You also get a response back. 64
Good Reads. 65
So within 4 seconds you're getting the response from both the sources and also from the database. 66
So basically you're getting all the detail you need within four seconds. 67
So you're saving it on two seconds. 68
So basically with concurrent programming we are able to better utilize our resources like VCP and due 69
to that we're able to get better throughput. 70
That as are able to get more things done in a given amount of time so that's being effective. 71
Just like the way we can be more effective if we read a newspaper when our coffee is getting better 72
right. 73
We're doing multiple activities at the same time so concurrent programming helps get better throughput 74
. 75
But it is also much more complex than sequential programming and understanding of concurrency is not 76
strong enough then it can be a lot of headaches. 77
So compared to sequential programming. 78
Much more good needs to be taken that concurrent programming. 79
So the goal of this chapter is to give you a very solid foundation in concurrency and we will not stop 80
it just fundamentals. 81
But we will learn some advance stuff to learn over concepts in two parts. 82
In the first part we will start by looking at the code multithreading related classes. 83
Then we will discuss a concurrency related issue that we can run into under diskless truck safety. 84
Then we will see how we can avoid such issues by using something called a locking mechanism which is 85
nothing which synchronization. 86
But if you discuss synchronization earlier in the course. 87
But here I'd be able to go in that and we would also discuss some recommendations. 88
Effective Java. 89
We will also discuss something called threat cooperation. 90
We will see how threats can cooperate with each other. 91
And then comes the second part where we will get into more advanced of which actually makes our lives 92
easier. 93
These are some higher level concurrent utilities which were it is in Java. 94
So everything we see in the part one is actually more of low level but in the second part we will see 95
some higher level concurrent difficulties on one of the main things we will see here is the executive 96
framework which is what you would use when it comes to large scale applications. 97
And we will do a lot of really good demos and we will see everything in action. 98
Finally I would also like to bring your attention to this book. 99
It is Java Concurrency in practice. 100
It is a book specific to concurrency and it comes from that been Houben some of the concurrency think 101
just in July itself. 102
You can think of it as DJO a book for currency and you are going to discuss some of the things from 103
this book. 104
If you're going to work on projects that don't work on current programming then you must read most of 105
this book and I would strongly suggest having a copy of this book along with the Java book. 106
In fact Joshua Bloch who wrote ethical Abdullah is also one of the authors of this book. 107
So that's about it. 108
So let's go ahead and get started. 109
And it will be a very exciting chapter. 110
Thank you