Welcome to Part four.
Now we're going to modify our threads to invoke future tasks instead of renewables because their own
method inside of a renewable is void, which means whatever value gets returned from average, it's
going to get swallowed into void into our workaround was to store this return value in a class level
variable before it gets swallowed.
But that's not really best practice.
Instead, what we want to do is have our thread execute a callable which holds on to the final value.
So here what we can do is say future task.
We expect a double to be returned.
Future.
Is equal to a new future task.
That expects a callable.
Here we can pass in our future task.
And we can repeat this.
Three more times it seems to.
And three, call this future two or three.
Future three.
Thread for.
And future for the Red five.
This is going to be technology.
This will be office supplies.
And here we'd be getting the total average.
All right, simple enough.
And now here we can just say.
Well, our classical variables are furniture, technology, supplies and average, respectively.
So here we can say furniture is equal to future except.
Technology is equal to future to don't get.
Do the same thing for I think it was called supplies.
Yeah.
Supplies equals future three, don't get.
And then we've got.
Average.
Is equal to a future for.
Get.
On handled exception, type execution exception for the sake of expediency will just catch all exceptions
in this one block and print the resulting error message.
And if we run the code.
Um, yeah, and.
You get the same results.
Perfect.