-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chapter 28 confirmation #88
Comments
Hi VishGov. You're right, the recommended way is to join the first task, I've changed the example. The text and the other examples also reflect this. However, in practice, most of the time it doesn't matter. Parallelism is a bit tricky to get it right, it depends on the complexity of the task and the number of cores of the computer executing the code. Some links: Thanks! |
Thanks for the StackOverflow references Esteban!
…On Mon, 4 Nov 2019, 2:45 am Esteban Herrera, ***@***.***> wrote:
Hi VishGov. You're right, the recommended way is to join the first task,
I've changed the example. The text and the other examples also reflect
this. However, in practice, most of the time it doesn't matter. Parallelism
is a bit tricky to get it right, it depends on the complexity of the task
and the number of cores of the computer executing the code.
Some links:
https://stackoverflow.com/questions/30242516/in-javas-forkjointask-does-the-order-of-fork-join-matter
https://stackoverflow.com/questions/50757332/forkjointask-order-of-join-ing
Thanks!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#88?email_source=notifications&email_token=ADFQTOHWZZNVBPVJREI3GD3QR45P7A5CNFSM4JIKYAGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC5476Q#issuecomment-549179386>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADFQTOAFU6JUS2MV34PB57DQR45P7ANCNFSM4JIKYAGA>
.
|
Hi Esteban,
In chapter 28 for the RecursiveTask example code,
FindMinimumAction firstSubtask =
new FindMinimumAction(data, start, mid);
FindMinimumAction secondSubtask =
new FindMinimumAction(data, mid, end);
// queue the first task
firstSubtask.fork();
// Return the miminum of all subtasks
return Math.min(firstSubtask.compute(),
secondSubtask.join());
Could you elaborate why we are forking AND also computing the first task, and then joining with the second?
From the notes, I thought that its generally the first is forked, the second computed and we wait on the result of the forked first task( which is usually "stolen" by another worker thread)
Or does it not really matter?
Thanks and Regards,
Vishnu
The text was updated successfully, but these errors were encountered: