Class FileProcessingTask
java.lang.Object
java.util.concurrent.ForkJoinTask<Void>
java.util.concurrent.RecursiveAction
topics.parallel.fileprocessing.FileProcessingTask
- All Implemented Interfaces:
Serializable, Future<Void>
Parallel File Processing (Fork/Join)
Demonstrates the divide-and-conquer pattern utilizing Java's RecursiveAction.
It recursively splits a list of files into smaller sub-tasks until they hit
the defined threshold, allowing the ForkJoinPool to process the I/O workload in parallel.
Modernization Note: Utilizes NIO.2 (Path, Files)
for robust and efficient filesystem traversal.
- Author:
- vicegd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Future
Future.State -
Constructor Summary
ConstructorsConstructorDescriptionFileProcessingTask(Path directory) Root Constructor: Initializes the task by scanning the target directory. -
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
-
FileProcessingTask
Root Constructor: Initializes the task by scanning the target directory.Utilizes Java Streams to efficiently filter and collect regular files, ignoring sub-directories.
- Parameters:
directory- The root directory to scan.
-
-
Method Details
-
compute
protected void compute()- Specified by:
computein classRecursiveAction
-