About Question enthuware.ocpjp.v7.2.1241 :
Moderator: admin
-
- Posts: 31
- Joined: Tue Oct 06, 2015 1:57 pm
- Contact:
About Question enthuware.ocpjp.v7.2.1241 :
I understand why answer choices 4 and 6 are correct but I do not understand why answer choice 1 is wrong? Is it because there is no requirement to return any value and therefore RecursiveTask is not optimal?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1241 :
Since the question is about the most correct approach, RecursiveTask is not as suitable as RecursiveAction. Yes, although not by much, a RecursiveTask will be at least an instruction slower than RecursiveAction because it returns a value, which is not required here.
HTH,
Paul.
HTH,
Paul.
-
- Posts: 23
- Joined: Sun Feb 21, 2016 10:12 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1241 :
But on contrary to this question if we look at question no - enthuware.ocpjp.v7.2.1238, on the line 15 it's saying that invokeAll is the correct method to call. But going through this question it seems that we should use compute for one part and fork the other part and then join them back. What am I missing ?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1241 :
They are showing two different approaches. If you have subdivided the tasks and if you want to do something only after all the subtasks are done, then you should use invokeAll because invokeAll will join on those tasks i.e. you will be waiting until all the tasks are done. invoke is works similarly for one task.
Basically, invoke/invokeAll method include the functionality of fork+join.
Explanations of 2.1241 or 2.1338 do not say one is the correct approach and one is wrong. Both are different approaches and they can be used as per situation.
HTH,
Paul.
Basically, invoke/invokeAll method include the functionality of fork+join.
Explanations of 2.1241 or 2.1338 do not say one is the correct approach and one is wrong. Both are different approaches and they can be used as per situation.
HTH,
Paul.
-
- Posts: 23
- Joined: Sun Feb 21, 2016 10:12 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1241 :
So, I understood as if I use invokeall() even for two tasks, its the same thing as doing fork and joining them explicitly.
-
- Posts: 23
- Joined: Sun Feb 21, 2016 10:12 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1241 :
Could you please specify some good resource to clear the concepts of ForkJoinPool correctly?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1241 :
You should start with the Oracle's official trail:https://docs.oracle.com/javase/tutorial ... kjoin.html
this one is good as well: http://tutorials.jenkov.com/java-util-c ... npool.html
this one is good as well: http://tutorials.jenkov.com/java-util-c ... npool.html
-
- Posts: 23
- Joined: Sun Feb 21, 2016 10:12 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1241 :
Thanks. Please check my 4th reply on this post from bottom.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1241 :
Yes, but I would suggest you to write a sample program and verify that.sumanenthu wrote:Thanks. Please check my 4th reply on this post from bottom.
Who is online
Users browsing this forum: No registered users and 3 guests