Page 1 of 1

About Question enthuware.ocpjp.v7.2.1257 :

Posted: Fri Jun 17, 2016 11:38 pm
by homeric
Please explain the options in a more elaborate manner.

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

Posted: Sat Jun 18, 2016 12:29 am
by admin
Can you tell me explanation to which option is not clear so that we can explain better?
Also, which book are you following?
Paul.

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

Posted: Sun Jun 19, 2016 7:19 am
by homeric
Please elaborate the first option. I am following the K&B book.

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

Posted: Sun Jun 19, 2016 10:04 am
by admin
The first option is just a statement of a fact from the JavaDoc API description given here: https://docs.oracle.com/javase/8/docs/a ... JoinPool--

The thread factory is explained here: https://docs.oracle.com/javase/8/docs/a ... ctory.html

All this means is that instead of directly doing new Thread to create threads, the responsibility to create threads is passed on to a thread factory. The thread factory may internally create a new thread or supply a existing one based on its policy.

HTH,
Paul.

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

Posted: Sat Jul 18, 2020 2:26 pm
by mayilb77@gmail.com
Pls can you explain fifth option ?

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

Posted: Sat Jul 18, 2020 11:03 pm
by admin
The fifth option is, "The tasks submitted to a ForkJoinPool sit on the leaves of the task tree." This option was seen by our content author on their actual exam (long time back) and so we added it here.

To be honest, I am not exactly sure what was the thought process behind this option but here is what it seems to be referring to:

While using the fork/join framework, conceptually, a big task is split into multiple subtasks, which themselves may be split further into sub-subtasks and so on. This generates the "task tree". The last level of the tree (i.e. the leaf nodes) comprise of tasks that are computed (instead of splitting further).

Implementation wise, however, the actual task tree generated could be a little different because of work stealing approach where other threads may steal any node of task tree. So, it is possible that the smallest piece of a task may not be the leaf node of the tree. It depends on the implementation of the framework.

You may want to go through this article for a more detailed discussion on this: http://moi.vonos.net/java/forkjoin/