OK, now, instead of defining for individual threads, the task was to create an executor service with
an appropriate number of active threads.
By that, all I meant is we're going to use the formula for CPU bound tasks.
So here, I'll say into a number of threads.
And we're going to get the number of processors that our application has access to.
And then we're going to use the executor service.
To create a new fixed threat pool with this amount of threats.
OK, now, instead of all this, we can just submit our tasks directly to the executor, executor,
executors submit.
We're going to submit this task.
As well as the three other ones.
Furniture technology.
Office supplies.
And it's total average.
And the great thing about this is since we are submitting callable tasks, then our submit method is
going to return a future object.
So we'll say future.
Double.
And they have to import this first.
OK.
Copy and paste this three more times.
Call this feature to Future three and future for.
Now what we can do is as the thread is executing the callable task, the callable task is retaining
that value and then we're going to use the future to get that value.
So here we'll say, Oh, everything's already being done for us so we can go ahead and run the code.
I forgot to shut down the executor, so here after everything has been done.
We'll say executor that shut down.
Controversy.
We were in the application.
Nice.