Package rocks.xmpp.util.concurrent
Class QueuedExecutorService
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- rocks.xmpp.util.concurrent.QueuedExecutorService
-
- All Implemented Interfaces:
Executor
,ExecutorService
- Direct Known Subclasses:
QueuedScheduledExecutorService
public class QueuedExecutorService extends AbstractExecutorService
Queues tasks and delegates them to aExecutor
in order.The resulting behavior is similar to a single threaded pool: Tasks submitted to this class are guaranteed to be executed in the same order as they were submitted, but potentially are executed by different threads of the delegate executor.
The typical use case is, that you share a single
ThreadPoolExecutor
among multiple instances of this class, which results in a low overall thread count (only the ones spawned by the delegate executor), but still have the in-order execution behavior of a single threaded pool.
-
-
Constructor Summary
Constructors Constructor Description QueuedExecutorService(Executor delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
awaitTermination(long timeout, TimeUnit unit)
void
execute(Runnable command)
boolean
isShutdown()
boolean
isTerminated()
void
shutdown()
List<Runnable>
shutdownNow()
-
-
-
Constructor Detail
-
QueuedExecutorService
public QueuedExecutorService(Executor delegate)
- Parameters:
delegate
- the executor that will handle the tasks
-
-
Method Detail
-
execute
public void execute(Runnable command)
-
shutdown
public void shutdown()
-
isShutdown
public boolean isShutdown()
-
isTerminated
public boolean isTerminated()
-
awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
- Throws:
InterruptedException
-
-