Class RecursiveTaskSum
- All Implemented Interfaces:
Serializable, Future<Double>
Parallel Array Summation (Fork/Join)
Implements a parallel reduction strategy using RecursiveTask to compute
the mathematical sum of an array of double primitives. It splits the
array into sub-segments until they fall within a specific sequential threshold,
then aggregates fractional calculations up the execution tree.
Complexity
- Time Complexity:
O(N)- Distributed work over P cores reduces real-world processing duration near toO(N/P). - Space Complexity:
O(log N)- Stack consumption matches the binary tree depth during splitting.
- Author:
- vicegd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Future
Future.State -
Constructor Summary
ConstructorsConstructorDescriptionRecursiveTaskSum(double[] data, int start, int end) Initializes a sum task for a dedicated boundary segment of the array. -
Method Summary
Methods inherited from class RecursiveTask
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
-
RecursiveTaskSum
public RecursiveTaskSum(double[] data, int start, int end) Initializes a sum task for a dedicated boundary segment of the array.- Parameters:
data- The source numerical array.start- The inclusive starting boundary index.end- The exclusive ending boundary index.
-
-
Method Details
-
compute
- Specified by:
computein classRecursiveTask<Double>
-