What would be the drawback to invoke many RecursiveAction in the following code?
class RecursiveActionThing extends RecursiveAction {
int numbers = 1000;
public RecursiveActionThing(int numbers)
{
this.numbers = numbers;
}
public void compute()
{
if (numbers<500)
{
for (int i =0;i<numbers;i++)
{
System.out.println(i);
}
}
else{
invokeAll(new RecursiveActionThing(numbers/2),new RecursiveActionThing(numbers/2), new RecursiveActionThing(numbers/2), new RecursiveActionThing(numbers/2));
}
}
}
So far I have only seen invoking 2 tasks, so probably doing the above invocation is going to create a massive overhead in creating all those tasks, however why is it allowed by placing a varargs as paramenter? In certain situation might be useful? Which ones? Thanks in advance.
There is a fine example of this in the test Classes supplied with jsr166, MatrixMultiply.java You can find it here