All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.
The new value of the element is generated by a utility class's static method, which takes in the existing value as a parameter and returns the new value.
But the answers are RecursiveAction, which does not return a value.
What am I missing here?
The utility class's method returns the value that you need to update the array element with. But don't have to return that value from RecursiveAction. Please go through the sample implementation provided in the explanation.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Hi,
Why is option 3 not correct?
"Create a RecursiveAction that subdivides the task and submit all such tasks to a ForkJoinPool. "
The answer states "There is no need to submit the sub tasks to the pool. Once you fork a subtask, it is automatically executed by the pool."
ForkJoinTask has the invokeAll methods:
"public static void invokeAll(ForkJoinTask<?>... tasks) ... Forks the given tasks"
"public static <T extends ForkJoinTask<?>> Collection<T> invokeAll(Collection<T> tasks) ...Forks all tasks in the specified collection"
So by dividing a computation into separate chunks and optionally loading it into a collection you you can use your RA subclass instance to invoke those sub tasks.
How is invoking invokeAll on a RA instance not "submitting the tasks to the ForkJoinPool"? A RA exists in a FJP; when you call invokeAll you're saying, "here's a bunch of tasks I want you to execute, go off and execute them" to the FJP. I.e. the FJP is running all the threads; if you call invokeAll you are forking the subtasks and it's the FJP's job to do the forking, isn't it?
I am not sure exactly what you mean. Can you put it in code?
Once you submit the first/main RA to FJP, there is no need to submit any other task to FJP. The RA will just fork subtasks, which will be executed by the FJP without explicitly submitting the tasks to it.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Hi! I am really very confused because I cannot understand why is first a fork and then a compute:
newtask2.fork();
newtask1.compute();
newtask2.join();
Whats the difference between fork and compute methods? Why not invoke two fork() and two join()?
Agree with answers 5 and 6. However not agree with possible implementation.
There is question about correct compute method.
methods fork and join should be invoked on left side when compute on right side.
newtask1.fork()
newtask2.compute()
newtask1.join()
or
invokeAll(newtask2, newtask1).
Example will work and compile but this is not a correct implementation in my opinion.
tanzwud wrote:Agree with answers 5 and 6. However not agree with possible implementation.
There is question about correct compute method.
methods fork and join should be invoked on left side when compute on right side.
Why do you think so? I don't see any reason why one is better than the other.
-Paul.
If you like our products and services, please help us by posting your review here.
Option 3 is a bit misleading. For example, I understood it like "Create a RecursiveAction (implementation details) and submit all such tasks to a ForkJoinPool." In other words, it's like "all such tasks" refer to our RecursiveAction implementation instances, not to subtasks. Though, it may be my problem, of course.