import java.util.concurrent.RecursiveTask;
class MyTask extends RecursiveTask<Integer> {
final int low;final int high;
static final int THRESHOLD = /*--*/ ;
MyTask (int low,int hight) {
this.low=low;this.high=hight;
}
Integer
computeDirectly() {
return null;
} /*..*/
protected void compute() {
if (high - low <= THRESHOLD)
return
computeDirectly();
int mid = (low + high) / 2;
invokeAll
(new MyTask (low,mid), new MyTask(mid,high));
}
}
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 of computation.
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
Risposta A e C
Riferimenti:
Nessun commento:
Posta un commento