This week's book giveaway is in the Go forum.
We're giving away four copies of Head First Go and have Jay McGavren on-line!
See this thread for details.
Win a copy of Head First Go this week in the Go forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

The ForkJoinTask: What is happening behind the scene?  RSS feed

Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
Become a Java guru with IntelliJ IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!