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?
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
Create Edit Print & Convert PDF Using Free API with Java