Package topics.parallel
package topics.parallel
Parallel algorithms using Java's Fork/Join Framework.
Parallel algorithms divide work among multiple processor cores to reduce
wall-clock time. This package demonstrates parallelisation through the
divide-and-conquer paradigm using ForkJoinPool
and its RecursiveAction /
RecursiveTask abstractions.
Key Concepts
- Work splitting — sub-problems below a threshold are solved sequentially to amortise task-creation overhead.
- Work stealing — idle threads steal tasks from busy threads' queues, maximising CPU utilisation.
- Amdahl's Law — speedup is bounded by the sequential fraction of the computation.
Classes in This Package
FibonacciAlgorithm— sequential Fibonacci baselineFibonacciTask— parallel Fibonacci viaRecursiveTaskFileProcessingTask— parallel file processingRecursiveActionComparison— compares sequential vs parallel actionsRecursiveActionSquare— parallel squaring viaRecursiveActionRecursiveTaskSum— parallel array sum viaRecursiveTask
-
ClassesClassDescriptionTo solve the classical Fibonacci algorithm using a recursive and inefficient algorithmTo calculate the Fibonacci of a number nTo calculate the cube root of the values of an arrayTo calculate the square of the values of an arrayTo calculate the addition of the values of an array