1
00:00:00,690 --> 00:00:01,710
Welcome to Part four.

2
00:00:01,740 --> 00:00:07,200
Now we're going to modify our threads to invoke future tasks instead of renewables because their own

3
00:00:07,200 --> 00:00:12,360
method inside of a renewable is void, which means whatever value gets returned from average, it's

4
00:00:12,360 --> 00:00:17,190
going to get swallowed into void into our workaround was to store this return value in a class level

5
00:00:17,190 --> 00:00:18,660
variable before it gets swallowed.

6
00:00:19,050 --> 00:00:21,390
But that's not really best practice.

7
00:00:21,420 --> 00:00:26,850
Instead, what we want to do is have our thread execute a callable which holds on to the final value.

8
00:00:26,970 --> 00:00:30,990
So here what we can do is say future task.

9
00:00:33,920 --> 00:00:35,960
We expect a double to be returned.

10
00:00:37,210 --> 00:00:37,660
Future.

11
00:00:38,710 --> 00:00:41,020
Is equal to a new future task.

12
00:00:45,050 --> 00:00:46,730
That expects a callable.

13
00:00:53,880 --> 00:00:56,070
Here we can pass in our future task.

14
00:00:58,230 --> 00:01:00,120
And we can repeat this.

15
00:01:01,220 --> 00:01:04,190
Three more times it seems to.

16
00:01:05,080 --> 00:01:09,160
And three, call this future two or three.

17
00:01:11,170 --> 00:01:12,190
Future three.

18
00:01:13,520 --> 00:01:14,420
Thread for.

19
00:01:16,890 --> 00:01:19,890
And future for the Red five.

20
00:01:22,450 --> 00:01:24,490
This is going to be technology.

21
00:01:26,670 --> 00:01:28,440
This will be office supplies.

22
00:01:29,650 --> 00:01:32,020
And here we'd be getting the total average.

23
00:01:52,170 --> 00:01:53,190
All right, simple enough.

24
00:01:53,220 --> 00:01:54,780
And now here we can just say.

25
00:01:56,540 --> 00:02:00,800
Well, our classical variables are furniture, technology, supplies and average, respectively.

26
00:02:01,040 --> 00:02:05,450
So here we can say furniture is equal to future except.

27
00:02:10,430 --> 00:02:13,340
Technology is equal to future to don't get.

28
00:02:17,640 --> 00:02:19,980
Do the same thing for I think it was called supplies.

29
00:02:20,640 --> 00:02:20,910
Yeah.

30
00:02:24,010 --> 00:02:26,650
Supplies equals future three, don't get.

31
00:02:28,500 --> 00:02:30,420
And then we've got.

32
00:02:31,680 --> 00:02:32,340
Average.

33
00:02:34,210 --> 00:02:35,620
Is equal to a future for.

34
00:02:37,180 --> 00:02:37,480
Get.

35
00:02:43,080 --> 00:02:49,260
On handled exception, type execution exception for the sake of expediency will just catch all exceptions

36
00:02:49,260 --> 00:02:53,010
in this one block and print the resulting error message.

37
00:02:53,640 --> 00:02:54,630
And if we run the code.

38
00:02:59,850 --> 00:03:01,560
Um, yeah, and.

39
00:03:02,620 --> 00:03:03,770
You get the same results.

40
00:03:03,790 --> 00:03:04,390
Perfect.

