Class ConcurrentExecutor
java.lang.Object
org.simpleframework.common.thread.ConcurrentExecutor
- All Implemented Interfaces:
Executor
The
ConcurrentExecutor object is used to execute tasks
in a thread pool. This creates a thread pool with an unbounded list
of outstanding tasks, which ensures that any system requesting
a task to be executed will not block when handing it over.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ExecutorQueueThis is the queue used to enqueue the tasks for execution. -
Constructor Summary
ConstructorsConstructorDescriptionConcurrentExecutor(Class type) Constructor for theConcurrentExecutorobject.ConcurrentExecutor(Class type, int size) Constructor for theConcurrentExecutorobject.ConcurrentExecutor(Class type, int rest, int active) Constructor for theConcurrentExecutorobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidTheexecutemethod is used to queue the task for execution.voidstop()This is used to stop the executor by interrupting all running tasks and shutting down the threads within the pool.voidstop(long wait) This is used to stop the executor by interrupting all running tasks and shutting down the threads within the pool.
-
Field Details
-
queue
This is the queue used to enqueue the tasks for execution.
-
-
Constructor Details
-
ConcurrentExecutor
Constructor for theConcurrentExecutorobject. This is used to create a pool of threads that can be used to execute arbitraryRunnabletasks. If the threads are busy this will simply enqueue the tasks and return.- Parameters:
type- this is the type of runnable that this accepts
-
ConcurrentExecutor
Constructor for theConcurrentExecutorobject. This is used to create a pool of threads that can be used to execute arbitraryRunnabletasks. If the threads are busy this will simply enqueue the tasks and return.- Parameters:
type- this is the type of runnable that this acceptssize- this is the number of threads to use in the pool
-
ConcurrentExecutor
Constructor for theConcurrentExecutorobject. This is used to create a pool of threads that can be used to execute arbitraryRunnabletasks. If the threads are busy this will simply enqueue the tasks and return.- Parameters:
type- this is the type of runnable that this acceptsrest- this is the number of threads to use in the poolactive- this is the maximum size the pool can grow to
-
-
Method Details
-
execute
Theexecutemethod is used to queue the task for execution. If all threads are busy the provided task is queued and waits until all current and outstanding tasks are finished. -
stop
public void stop()This is used to stop the executor by interrupting all running tasks and shutting down the threads within the pool. This will return once it has been stopped, and no further tasks will be accepted by this pool for execution. -
stop
public void stop(long wait) This is used to stop the executor by interrupting all running tasks and shutting down the threads within the pool. This will return once it has been stopped, and no further tasks will be accepted by this pool for execution.- Parameters:
wait- the number of milliseconds to wait for it to stop
-