Package org.apache.hadoop.util
Class BlockingThreadPoolExecutorService
java.lang.Object
org.apache.hadoop.thirdparty.com.google.common.collect.ForwardingObject
org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ForwardingExecutorService
org.apache.hadoop.util.SemaphoredDelegatingExecutor
org.apache.hadoop.util.BlockingThreadPoolExecutorService
- All Implemented Interfaces:
Executor,ExecutorService
This ExecutorService blocks the submission of new tasks when its queue is
already full by using a semaphore. Task submissions require permits, task
completions release permits.
This is inspired by this s4 threadpool
-
Method Summary
Modifier and TypeMethodDescriptionstatic ThreadFactorynewDaemonThreadFactory(String prefix) Get a namedThreadFactorythat just builds daemon threads.newInstance(int activeTasks, int waitingTasks, long keepAliveTime, TimeUnit unit, String prefixName) A thread pool that that blocks clients submitting additional tasks if there are alreadyactiveTasksrunning threads andwaitingTaskstasks waiting in its queue.toString()Methods inherited from class org.apache.hadoop.util.SemaphoredDelegatingExecutor
delegate, execute, getAvailablePermits, getPermitCount, getWaitingCount, invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submitMethods inherited from class org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ForwardingExecutorService
awaitTermination, isShutdown, isTerminated, shutdown, shutdownNow
-
Method Details
-
newDaemonThreadFactory
Get a namedThreadFactorythat just builds daemon threads.- Parameters:
prefix- name prefix for all threads created from the factory- Returns:
- a thread factory that creates named, daemon threads with the supplied exception handler and normal priority
-
newInstance
public static BlockingThreadPoolExecutorService newInstance(int activeTasks, int waitingTasks, long keepAliveTime, TimeUnit unit, String prefixName) A thread pool that that blocks clients submitting additional tasks if there are alreadyactiveTasksrunning threads andwaitingTaskstasks waiting in its queue.- Parameters:
activeTasks- maximum number of active taskswaitingTasks- maximum number of waiting taskskeepAliveTime- time until threads are cleaned up inunitunit- time unitprefixName- prefix of name for threads- Returns:
- BlockingThreadPoolExecutorService.
-
toString
- Overrides:
toStringin classSemaphoredDelegatingExecutor
-