Question: Future type. I would use a standard array for this to help with output later rather than a built - in java class. This time
Future type. I would use a standard array for this to help with output later rather
than a builtin java class. This time you will create an ExecutorService with a ThreadPool type
of newCachedThreadPool type. This will create threads as needed to meet the demand.
Next, the program should create sampleCallable objects and submit them for execution to
the ExecutorService object and, as you saw in part a it should store the results into the array
of Futures for later access.
Once again, the main method should iterate through the List of Futures but this time note that
an actual useful value IS being returned. It will be the Integer representing the square that
particular callable thread produced. I would suggest that you use a for loop to walk through the
array calling the get method on the Futures and printing out the results as they are received.
Be sure the output matches in terms of thread numbers the correct values.
Once again, when you get through the loop all threads will have produced their results.
shutdown the ExecutorService object, sleep for a couple of seconds and then end the
program. Help me with create appropiarte ccp and h for class and main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
