Page 1 of 1

About Question enthuware.ocpjp.v7.2.1241 :

Posted: Sat Jan 30, 2016 7:38 pm
by krohani
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?

Re: About Question enthuware.ocpjp.v7.2.1241 :

Posted: Sat Jan 30, 2016 9:24 pm
by admin
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.

Re: About Question enthuware.ocpjp.v7.2.1241 :

Posted: Mon Mar 21, 2016 12:04 am
by sumanenthu
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 ?

Re: About Question enthuware.ocpjp.v7.2.1241 :

Posted: Mon Mar 21, 2016 9:07 pm
by admin
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.

Re: About Question enthuware.ocpjp.v7.2.1241 :

Posted: Mon Mar 21, 2016 11:27 pm
by sumanenthu
So, I understood as if I use invokeall() even for two tasks, its the same thing as doing fork and joining them explicitly.

Re: About Question enthuware.ocpjp.v7.2.1241 :

Posted: Tue Mar 22, 2016 4:08 am
by sumanenthu
Could you please specify some good resource to clear the concepts of ForkJoinPool correctly?

Re: About Question enthuware.ocpjp.v7.2.1241 :

Posted: Tue Mar 22, 2016 9:28 am
by admin
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

Re: About Question enthuware.ocpjp.v7.2.1241 :

Posted: Wed Mar 23, 2016 8:07 am
by sumanenthu
Thanks. Please check my 4th reply on this post from bottom.

Re: About Question enthuware.ocpjp.v7.2.1241 :

Posted: Wed Mar 23, 2016 9:22 am
by admin
sumanenthu wrote:Thanks. Please check my 4th reply on this post from bottom.
Yes, but I would suggest you to write a sample program and verify that.