You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/practice/parallel-letter-frequency/.approaches/introduction.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,11 @@ A [`map`][map], being a key-value pair structure, is suitable for recording freq
10
10
If the data being counted has a limited range (e.g., `Characters` or `Integers`), an `int[] array` or [`List<Integer>`][list] can be used to record frequencies.
11
11
12
12
Parallel processing typically takes place in a multi-[`thread`][thread] environment.
13
-
The Java 8 [`stream`][stream] API provides methods that make parallel processing easier, including the `parallelStream()` method.
14
-
With `parallelStream()`, developers can use the [`ForkJoinPool`][ForkJoinPool] model for workload division and parallel execution, without the need to manually manage threads or create custom thread pools.
13
+
The Java 8 [`stream`][stream] API provides methods that make parallel processing easier, including the [`parallelStream()`][stream] method.
14
+
With [`parallelStream()`][stream], developers can use the [`ForkJoinPool`][ForkJoinPool] model for workload division and parallel execution, without the need to manually manage threads or create custom thread pools.
15
15
16
16
The [`ForkJoinPool`][ForkJoinPool] class, optimized for dividing and managing tasks, makes parallel processing efficient.
17
-
However, `parallelStream()` uses the common [`ForkJoinPool`][ForkJoinPool] by default, meaning multiple `parallelStream` instances share the same thread pool unless configured otherwise.
17
+
However, [`parallelStream()`][stream] uses the common [`ForkJoinPool`][ForkJoinPool] by default, meaning multiple [`parallelStream`][stream] instances share the same thread pool unless configured otherwise.
18
18
19
19
As a result, parallel streams may interfere with each other when sharing this thread pool, potentially affecting performance.
20
20
Although this doesn’t directly impact solving the Parallel Letter Frequency problem, it may introduce issues when thread pool sharing causes conflicts in other applications.
@@ -130,7 +130,7 @@ For more information, check the [`fork/join` approach][approach-fork-join].
130
130
131
131
## Which approach to use?
132
132
133
-
When tasks are simple or do not require a dedicated thread pool (such as in this case), the `parallelStream` approach is recommended.
133
+
When tasks are simple or do not require a dedicated thread pool (such as in this case), the [`parallelStream`][stream] approach is recommended.
134
134
However, if the work is complex or there is a need to isolate thread pools from other concurrent tasks, the [`ForkJoinPool`][ForkJoinPool] approach is preferable.
0 commit comments