correction

This commit is contained in:
Luca Conte 2025-05-22 11:36:22 +02:00
parent dab09d6657
commit c18ccf1e43
2 changed files with 1 additions and 4 deletions

View File

@ -21,7 +21,7 @@ is better suited to independent tasks because ...".
`ThreadPoolExecutor` is better suited for long running tasks, because `join()` executes another task while waiting for the current one to finish, therefore possibly waiting longer than strictly necessary.
`ForkJoinPool` is better suited for short running tasks because it creates less synchronization overhead than `ThreadPoolExecutor` and it uses a stack instead of a FiFo Queue to allow the newest tasks to be executed first (which also makes it better suited for mutually dependent tasks, since the waiting time for `join()`ing tasks is minimized)
`ForkJoinPool` is better suited for short running tasks because it uses seperate stacks for each thread, therefore avoiding synchronization overhead when taking new tasks.
Tasks usually create other tasks if they are dependent on that task, so since `ForkJoinPool` is better suited for mutually dependent tasks, it is also better suited for tasks that create other tasks.

View File

@ -10,11 +10,8 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.Future;
import java.util.concurrent.RecursiveAction;
import java.util.concurrent.RecursiveTask;
import java.util.concurrent.ThreadPoolExecutor;
/**
* Construct a binary tree and compute the sum over all tree nodes