Class RecursiveActionSquare
java.lang.Object
java.util.concurrent.ForkJoinTask<Void>
java.util.concurrent.RecursiveAction
topics.parallel.square.RecursiveActionSquare
- All Implemented Interfaces:
Serializable, Future<Void>
Parallel Array Squaring (Fork/Join)
Implements a parallel divide-and-conquer strategy using RecursiveAction
to compute the square of each integer in a shared array in-place.
Complexity
- Time Complexity:
O(N)- Total work remains linear, but runtime is reduced structurally by a factor proportional to the active hardware core count. - Space Complexity:
O(log N)- Stack depth of the thread pool corresponds directly to the binary decomposition height.
- Author:
- vicegd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Future
Future.State -
Constructor Summary
ConstructorsConstructorDescriptionRecursiveActionSquare(int[] data, int start, int end) Initializes the parallel action for a targeted 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
-
RecursiveActionSquare
public RecursiveActionSquare(int[] data, int start, int end) Initializes the parallel action for a targeted segment of the array.- Parameters:
data- The shared array to mutate in-place.start- The inclusive starting boundary index.end- The exclusive ending boundary index.
-
-
Method Details
-
compute
protected void compute()- Specified by:
computein classRecursiveAction
-