Class RecursiveActionComparison
java.lang.Object
java.util.concurrent.ForkJoinTask<Void>
java.util.concurrent.RecursiveAction
topics.parallel.cuberoot.RecursiveActionComparison
- All Implemented Interfaces:
Serializable, Future<Void>
Parallel Array Transformation (Fork/Join)
Demonstrates the divide-and-conquer pattern utilizing RecursiveAction
to mutate a shared array in-place. It calculates the mathematical cube root
for each element, distributing the workload across multiple threads.
- Author:
- vicegd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Future
Future.State -
Constructor Summary
ConstructorsConstructorDescriptionRecursiveActionComparison(int[] data, int start, int end, int threshold) Initializes the parallel action for a specific segment of the array. -
Method Summary
Methods inherited from class RecursiveAction
exec, getRawResult, setRawResultMethods inherited from class ForkJoinTask
adapt, adapt, adapt, adaptInterruptible, adaptInterruptible, adaptInterruptible, cancel, compareAndSetForkJoinTaskTag, complete, completeExceptionally, exceptionNow, fork, get, get, getException, getForkJoinTaskTag, getPool, getQueuedTaskCount, getSurplusQueuedTaskCount, helpQuiesce, inForkJoinPool, invoke, invokeAll, invokeAll, invokeAll, isCancelled, isCompletedAbnormally, isCompletedNormally, isDone, join, peekNextLocalTask, pollNextLocalTask, pollSubmission, pollTask, quietlyComplete, quietlyInvoke, quietlyJoin, quietlyJoin, quietlyJoinUninterruptibly, reinitialize, resultNow, setForkJoinTaskTag, state, tryUnfork
-
Constructor Details
-
RecursiveActionComparison
public RecursiveActionComparison(int[] data, int start, int end, int threshold) Initializes the parallel action for a specific segment of the array.- Parameters:
data- The shared array to be mutated in-place.start- The inclusive starting index of the segment.end- The exclusive ending index of the segment.threshold- The granularity limit. Segments smaller than this are processed sequentially.
-
-
Method Details
-
compute
protected void compute()- Specified by:
computein classRecursiveAction
-