Which two changes make the program work correctly?

Given the following incorrect program:

Which two changes make the program work correctly?

Given the following incorrect program:

Which two changes make the program work correctly?

A.
Results must be retrieved from the newly created MyTask instances and combined.

B.
The threshold value must be increased so that the overhead of task creation does not dominate
the cost ofcomputation.

C.
The midpoint computation must be altered so that it splits the workload in an optimal manner.

D.
The compute () method must be changed to return an Integer result.

E.
The compute () method must be enhanced to (fork) newly created tasks.

F.
The myTask class must be modified to extend RecursiveAction instead of RecursiveTask

Explanation:

Note 1: A RecursiveTask is a recursive result-bearing ForkJoinTask.
Note 2: The invokeAll(ForkJoinTask<?>… tasks) forks the given tasks, returning when isDone
holds for eachtask or an (unchecked) exception is encountered, in which case the exception is
rethrown.
Note 3: Using the fork/join framework is simple. The first step is to write some code that performs
a segmentof the work. Your code should look similar to this:
if (my portion of the work is small enough)
do the work directly
else
split my work into two pieces

invoke the two pieces and wait for the results
Wrap this code as a ForkJoinTask subclass, typically as one of its more specialized types
RecursiveTask
(which can return a result) or RecursiveAction.



Leave a Reply 0

Your email address will not be published. Required fields are marked *