Christophe De Troyer Christophe De Troyer - 9 months ago 59
Java Question

ForkJoinPool.invokeAll(ArrayList<G extends RecursiveTask<T>)

I'm trying to invoke a list of

instances on a
but it's complaining about the types.

I'm not pretty sure why it's not working.

I have the task classes which are defined as follows:

public class WorkerTask<G extends Game> extends RecursiveTask<Double>

I create
of these tasks and then I would like to let them loose in a
. I know I can invoke them one by one using
but that's not what I want in the end.

The docs tell me that it has to be a list of objects that implement
. I followed the type hierarchy upwards up to
. There I can see a class defined
static final class AdaptedCallable<T> extends ForkJoinTask<T>
so I think it should work.

What am I doing wrong here?

Answer Source

According to the api ForkJoinTask doesn't implement any Callable interface?

Looking at this example I'm not sure you're supposed to be using the invokeAll on the ForkJoinPool. You're supposed to add new WorkerTask to a list in the compute method itself and then call invokeAll(List<WorkerTask>).