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