Skip to content

Commit c2cfccc

Browse files
committed
Adds more information about ForkJoin Framework
1 parent e6896b4 commit c2cfccc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/br/com/leonardoz/features/forkjoin/UsingForkJoinFramework.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
*
2626
* One requirement for using the Fork/Join Framework is that all of the Subtasks
2727
* must be "completable and independent" of each other to be truly parallel, so
28-
* not every problem can be solved using this method.
28+
* not every problem can be solved using this method. In general, the ForkJoin Framework
29+
* is to be used by CPU-intensive computations, not IO bound computations, due to the
30+
* long wait periods that could happen.
2931
*
3032
* How it works
3133
*
@@ -90,7 +92,7 @@ public class UsingForkJoinFramework {
9092
* Default instance of a fork join pool in a Java app, used by
9193
* CompletableFuture, and parallel streams. All threads used by the common pool
9294
* can be reused, released and reinstated after some time. This approach reduces
93-
* the resource consumption.
95+
* the resource consumption. It doesn't need to be closed/shutdown.
9496
*
9597
*/
9698
public ForkJoinPool getCommonPool() {
@@ -112,8 +114,10 @@ public ForkJoinPool getCommonPool() {
112114
* joined, like event-oriented asynchronous tasks.
113115
*
114116
*/
115-
public ForkJoinPool customForkJoinPool(int parallelism, ForkJoinPool.ForkJoinWorkerThreadFactory factory,
116-
UncaughtExceptionHandler handler, boolean asyncMode) {
117+
public ForkJoinPool customForkJoinPool(int parallelism,
118+
ForkJoinPool.ForkJoinWorkerThreadFactory factory,
119+
UncaughtExceptionHandler handler,
120+
boolean asyncMode) {
117121
return new ForkJoinPool(parallelism, factory, handler, asyncMode);
118122
}
119123

0 commit comments

Comments
 (0)