Class MoreExecutors.DirectExecutorService
java.lang.Object
java.util.concurrent.AbstractExecutorService
com.google.common.util.concurrent.AbstractListeningExecutorService
com.google.common.util.concurrent.MoreExecutors.DirectExecutorService
- All Implemented Interfaces:
ListeningExecutorService,Executor,ExecutorService
- Enclosing class:
- MoreExecutors
private static final class MoreExecutors.DirectExecutorService
extends AbstractListeningExecutorService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ObjectLock used whenever accessing the state variables (runningTasks, shutdown) of the executorprivate intprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) private voidendTask()Decrements the running task count.voidbooleanbooleanvoidshutdown()private voidChecks if the executor has been shut down and increments the running task count.Methods inherited from class com.google.common.util.concurrent.AbstractListeningExecutorService
newTaskFor, newTaskFor, submit, submit, submitMethods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAnyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.ExecutorService
invokeAny, invokeAnyMethods inherited from interface com.google.common.util.concurrent.ListeningExecutorService
invokeAll, invokeAll
-
Field Details
-
lock
Lock used whenever accessing the state variables (runningTasks, shutdown) of the executor -
runningTasks
private int runningTasks -
shutdown
private boolean shutdown
-
-
Constructor Details
-
DirectExecutorService
private DirectExecutorService()
-
-
Method Details
-
execute
-
isShutdown
public boolean isShutdown() -
shutdown
public void shutdown() -
shutdownNow
-
isTerminated
public boolean isTerminated() -
awaitTermination
- Throws:
InterruptedException
-
startTask
private void startTask()Checks if the executor has been shut down and increments the running task count.- Throws:
RejectedExecutionException- if the executor has been previously shutdown
-
endTask
private void endTask()Decrements the running task count.
-