Class SingleLaneExecutorService
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- hudson.remoting.SingleLaneExecutorService
-
- All Implemented Interfaces:
Executor
,ExecutorService
public class SingleLaneExecutorService extends AbstractExecutorService
Creates anExecutorService
that executes submitted tasks sequentially on top of another generic arbitraryExecutorService
.In general,
ExecutorService
do not place constraints about the order in which submitted tasks are executed. This class takes such an executor service, then creates a stronger guarantee on the order of the executions. Namely, the submitted tasks are executed in the FIFO order, and no two tasks are executed concurrently.A large number of
SingleLaneExecutorService
s backed by a single cached executor service is more efficient than the same number of single-threadedExecutorService
because of the thread sharing.This class is named
SingleLaneExecutorService
because it's akin to create a driving lane in a high way. You can have many lanes, but each lane is strictly sequentially ordered.- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Constructor Description SingleLaneExecutorService(ExecutorService base)
-
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()
-
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
-
-
-
Constructor Detail
-
SingleLaneExecutorService
public SingleLaneExecutorService(ExecutorService base)
- Parameters:
base
- Executor service that actually provides the threads that execute tasks.
-
-
Method Detail
-
shutdown
public void shutdown()
Note that this does not shutdown the wrapped
ExecutorService
.
-
shutdownNow
@NonNull public List<Runnable> shutdownNow()
Note that this does not shutdown the wrapped
ExecutorService
.
-
isShutdown
public boolean isShutdown()
-
isTerminated
public boolean isTerminated()
-
awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
- Throws:
InterruptedException
-
execute
public void execute(@NonNull Runnable command)
-
-