﻿1
00:00:00,710 --> 00:00:04,580
was gone as welcomes your second
tutorial in java game development

2
00:00:04,580 --> 00:00:08,900
and in this story wrongly actually
finishing up the last story re pretty

3
00:00:08,900 --> 00:00:10,460
much argun finish creating a

4
00:00:10,460 --> 00:00:14,030
to read and well let's just go ahead and
get started

5
00:00:14,030 --> 00:00:18,510
so actually we need a main method in
there so let's go ahead and I probably

6
00:00:18,510 --> 00:00:19,820
should done that before

7
00:00:19,820 --> 00:00:22,960
but I can do now published static void

8
00:00:22,960 --> 00:00:29,960
main stirring my heart's

9
00:00:30,429 --> 00:00:34,120
arch stadiums go ahead and put main
matter to rate their

10
00:00:34,120 --> 00:00:38,379
so in our main matted again I should
done that before but oh well

11
00:00:38,379 --> 00:00:42,599
you guys ass in time what you need to do
in order to make threats

12
00:00:42,600 --> 00:00:46,210
is call caps lock on the up

13
00:00:46,210 --> 00:00:51,190
is to read class go ahead and both red
and then a mentor and I'm gon a mighty

14
00:00:51,190 --> 00:00:51,769
one

15
00:00:51,770 --> 00:00:55,879
and said he quit in New to read but as
your parameter

16
00:00:55,879 --> 00:00:59,640
for this third class yes to rate the
object that you want to treat

17
00:00:59,640 --> 00:01:04,809
as a dread sewed new Apple remember I
made this Apple class rehear their organ

18
00:01:04,809 --> 00:01:06,100
meat reading is a thread

19
00:01:06,100 --> 00:01:10,250
and the constructor took a pram nerd and
I'm can name it

20
00:01:10,250 --> 00:01:15,150
1 so this thread that has the variable
t1

21
00:01:15,150 --> 00:01:19,400
is gon be named one so let's go ahead
and make

22
00:01:19,400 --> 00:01:24,509
two more right now arm again we're gon
be creating three threads

23
00:01:24,509 --> 00:01:28,409
from the same class in a min im this
want t2

24
00:01:28,409 --> 00:01:33,079
and the variable 23 in threads name is
going to me

25
00:01:33,079 --> 00:01:36,140
to and three

26
00:01:36,140 --> 00:01:39,520
and if your honor I and type in 1 2-3
it's because this

27
00:01:39,520 --> 00:01:45,429
Apple constructor remember we passed in
a string variable to give a name

28
00:01:45,430 --> 00:01:50,560
right there and then arm upon to show
action and object to create a random

29
00:01:50,560 --> 00:01:51,110
time

30
00:01:51,110 --> 00:01:54,119
so now that we have left to read

31
00:01:54,119 --> 00:01:57,159
this pretty much means each of these
things

32
00:01:57,159 --> 00:02:01,280
instead running array after another like
they would have their just

33
00:02:01,280 --> 00:02:05,229
a regular object they can all run at the
same time

34
00:02:05,229 --> 00:02:08,310
so before we learned about threads

35
00:02:08,310 --> 00:02:13,129
whenever we created a new Apple class it
would have to do the constructor

36
00:02:13,129 --> 00:02:17,440
into everything ended first before
moving on to this one and then

37
00:02:17,440 --> 00:02:20,579
after that in mood and this one but

38
00:02:20,580 --> 00:02:25,330
now now we have three threads and
several one long program in essence

39
00:02:25,330 --> 00:02:29,050
this is three things running at the same
time

40
00:02:29,050 --> 00:02:32,530
so we get some three times as fast is a
usually would

41
00:02:32,530 --> 00:02:35,890
sahnoun that we have a thread

42
00:02:35,890 --> 00:02:38,980
we need to start it so what star

43
00:02:38,980 --> 00:02:43,369
whenever we costar the objects or
threads run

44
00:02:43,370 --> 00:02:46,900
is on Mac league can be called we don't
have to call Ron

45
00:02:46,900 --> 00:02:50,840
we all we have to do is call star in any
cold in here

46
00:02:50,840 --> 00:02:54,239
in thread to run is gonna on Mac would
be called

47
00:02:54,239 --> 00:02:57,489
so how do we do that all we do is t1 dot

48
00:02:57,489 --> 00:03:01,590
start to rate their in this is gonna
start a thread or in other words start

49
00:03:01,590 --> 00:03:02,879
the code in here

50
00:03:02,879 --> 00:03:07,129
so t1 just copy this t2

51
00:03:07,129 --> 00:03:11,540
nt-3 and why did I make this ran a time

52
00:03:11,540 --> 00:03:16,429
washoe your eye in a second if I go
ahead and click his application

53
00:03:16,430 --> 00:03:20,030
run it and I forgot to put

54
00:03:20,030 --> 00:03:24,980
a new line rehear an embarrassing in
Alameda mystery that again

55
00:03:24,980 --> 00:03:28,620
it says one

56
00:03:28,620 --> 00:03:32,450
is sleeping 4 for 19 three is sleeping

57
00:03:32,450 --> 00:03:36,590
for 876 and to is sleeping for 189

58
00:03:36,590 --> 00:03:40,000
interest in Ari why doesn't he just go
1-2-3

59
00:03:40,000 --> 00:03:43,120
well that's because your computer dozen

60
00:03:43,120 --> 00:03:46,739
do in it doesn't have to do when you
create threads

61
00:03:46,739 --> 00:03:50,569
in order one right after another and
that's the beauty of threats

62
00:03:50,569 --> 00:03:53,739
these pretty much star all at the same
time

63
00:03:53,739 --> 00:03:58,530
arm I mean there's little bit different
by in essence they all started the same

64
00:03:58,530 --> 00:03:59,159
time

65
00:03:59,159 --> 00:04:02,989
and why did I put how long sleeves for
because

66
00:04:02,989 --> 00:04:06,599
wanna Brent sleeps it pretty much does
nothing

67
00:04:06,599 --> 00:04:12,000
but wait there it doesn't arm poll
burden on your CPU processor no

68
00:04:12,000 --> 00:04:15,090
it just sits there in weights their in

69
00:04:15,090 --> 00:04:19,750
it pretty much the last for other stuff
to happen suffer centauri

70
00:04:19,750 --> 00:04:23,770
when this thread is done I want you to
sleep in wafer other threats

71
00:04:23,770 --> 00:04:28,099
so well went to his sleeping a pretty
much just sittin there

72
00:04:28,100 --> 00:04:32,199
in chilling so that's why once each for
attentive or exceeding like a twenty

73
00:04:32,199 --> 00:04:33,870
years

74
00:04:33,870 --> 00:04:38,540
or .1 a up a sec in then this one gets
done sleeping first

75
00:04:38,540 --> 00:04:41,880
the next one to wake up is train number
one because

76
00:04:41,880 --> 00:04:45,909
it slut a medium amount of time but
three it was a lease in the side is

77
00:04:45,910 --> 00:04:47,130
sleep the longest

78
00:04:47,130 --> 00:04:51,050
that's why three got done running so
late so again

79
00:04:51,050 --> 00:04:55,580
but i wanna demonstrate is instead going
ray after another one

80
00:04:55,580 --> 00:04:58,740
to 3 these things run pretty much

81
00:04:58,740 --> 00:05:02,060
out the same sup same time so it's
pretty much a randomized

82
00:05:02,060 --> 00:05:06,880
11 is gonna be your first and this is
also a random and I wanna

83
00:05:06,880 --> 00:05:11,360
display this because arm this says
Wallace sleeping

84
00:05:11,360 --> 00:05:15,199
it allows other threads to continue
doing what they do

85
00:05:15,199 --> 00:05:18,380
so this is kinda the beauty of threads
one more time there

86
00:05:18,380 --> 00:05:21,509
you can have multiple things running at
the same time

87
00:05:21,509 --> 00:05:25,610
in this speeds up your program that's
all I want explain for this story I'll

88
00:05:25,610 --> 00:05:30,169
there is a ton more to go over in
threads but for

89
00:05:30,169 --> 00:05:33,698
arm the second this store oh that's all
we need to know for now

90
00:05:33,699 --> 00:05:38,759
as we continue programming in games will
learn later and even that this doesn't

91
00:05:38,759 --> 00:05:41,520
make sense now when I start using in the
game

92
00:05:41,520 --> 00:05:45,880
sometimes Aegis examples using it can be
kinda makes using cuz it doesn't really

93
00:05:45,880 --> 00:05:47,780
do anything is just an example

94
00:05:47,780 --> 00:05:50,860
but trust me why you'll see why this is
useful later on

95
00:05:50,860 --> 00:05:54,400
by needed to give you guys a quick intro
or routes I would never forgive myself

96
00:05:54,400 --> 00:05:55,590
for

97
00:05:55,590 --> 00:05:58,680
so that's all you need to know about
threads for now if you wanna learn more

98
00:05:58,680 --> 00:06:02,150
than got the job a website or something
or just wait for my tutorials

99
00:06:02,150 --> 00:06:06,850
but for now thank yes ru watchin I don't
get check out the next door to where we

100
00:06:06,850 --> 00:06:08,400
will be pretty much

101
00:06:08,400 --> 00:06:11,940
building our very first beginning have a
job a game

102
00:06:11,940 --> 00:06:15,259
so thank you again don't you subscribe
to now see next door


