public class LocalPoolExecutor extends Object implements Executor
Executor.Status
Modifier and Type | Field and Description |
---|---|
private Callable<?> |
job |
private int |
numRuns |
private boolean |
ok |
private int |
poolSize |
private ExecutorService |
service |
private Executor.Status |
status |
Constructor and Description |
---|
LocalPoolExecutor(int threadPoolSize,
int numInstancesToRun,
Callable<?> callable)
Create the Callable executor that will run a supplied number of instances of a supplied callable, canceling the execution
if a thread throws an exception.
|
LocalPoolExecutor(int threadPoolSize,
List<Callable<?>> jobs)
Create the Callable executor that will run each callable in a collection, canceling the execution
if a thread throws an exception.
|
Modifier and Type | Method and Description |
---|---|
Executor.Status |
getStatus()
Get the current status of the jobs in the executor.
|
void |
run()
Run the required number of jobs, checking for thrown exceptions once each task has completed.
|
private void |
shutdown()
Shutdown the ExecutionService, blocking until ALL the threads have finished before returning.
|
private void |
stopAllTasks(List<Future<?>> tasks)
Send a message to all the futures to cancel their execution.
|
private final int poolSize
private final int numRuns
private final Callable<?> job
private final ExecutorService service
private Executor.Status status
private boolean ok
public LocalPoolExecutor(int threadPoolSize, int numInstancesToRun, Callable<?> callable)
threadPoolSize
- the number of concurrent threads to be run (the size of the thread pool)numInstancesToRun
- the number of threads to be run.callable
- the actual Callable instance that is to be executed in the pool.public LocalPoolExecutor(int threadPoolSize, List<Callable<?>> jobs)
threadPoolSize
- the number of concurrent threads to be run (the size of the thread pool)jobs
- a collection of [Callable] jobs to be run.public final Executor.Status getStatus()
Executor
public final void run()
Executor
private void stopAllTasks(List<Future<?>> tasks)
tasks
- a collection of future object that are to be stopped.private void shutdown()
Copyright © 2015 University of Glasgow. All rights reserved.