Source of codes:
Java 8 in Action: Lambdas, streams, and functional-style programming
(Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft) Page 217.
The ForkJoinSumCalculator class extended the ForkJoinTask class. The line of code ForkJoinTask<Long> task = new ForkJoinSumCalculator(numbers); effectively creates a ForkJoinTask object from a ForkJoinSumCalculator class. That means the instance named task does not have the fields and methods defined in the ForkJoinSumCalculator class. Example,
Long m = task.compute(); //Error: cannot find symbol. This confirms to me that the compute() method is not in task.
The thing is the program runs and produces a sum.
So, I ask, what is going on behind the scene?
What is invoking the compute() method?
On which instance is the compute() method being invoked?
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad: