public abstract class MultiThreadedTask<ResultType> extends Object
List<ResultFromSingleThread> results = new MultiThreadedTask<ResultFromSingleThread>() {MultiThreadedProcessingSystem| Constructor and Description |
|---|
MultiThreadedTask()
Creates a task split over a number of threads equal to the number of processors available on this machine.
|
MultiThreadedTask(int numberOfThreads)
Creates a task split over the specified number of threads
|
| Modifier and Type | Method and Description |
|---|---|
static int |
getNumberOfProcessors() |
List<ResultType> |
run()
Creates threads, executes all the parts and waits for them to finish before returning.
|
abstract ResultType |
run(int partNumber,
int numberOfParts)
Runs a part of this task in a single thread.
|
public MultiThreadedTask()
public MultiThreadedTask(int numberOfThreads)
numberOfThreads - the number of threadspublic static int getNumberOfProcessors()
public abstract ResultType run(int partNumber, int numberOfParts)
partNumber - the part number of this part of the task between 0 and numberOfParts-1 inclusive.numberOfParts - the total number of parts this task has been split into.public List<ResultType> run()