BlockingThreadPoolExecutorService (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: BlockingThreadPoolExecutorService

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`

@Private public final class BlockingThreadPoolExecutorService extends SemaphoredDelegatingExecutor
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 Type
  Method
  Description
  `static ThreadFactory`
  `newDaemonThreadFactory(String prefix)`
  Get a named `ThreadFactory` that just builds daemon threads.
  `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 already `activeTasks` running threads and `waitingTasks` tasks waiting in its queue.
  `String`
  `toString()`

  ### Methods inherited from class org.apache.hadoop.util.SemaphoredDelegatingExecutor

  `delegate, execute, getAvailablePermits, getPermitCount, getWaitingCount, invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit`

  ### Methods inherited from class org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ForwardingExecutorService

  `awaitTermination, isShutdown, isTerminated, shutdown, shutdownNow`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Method Details

  - ### newDaemonThreadFactory

    public static ThreadFactory newDaemonThreadFactory(String prefix)
    Get a named `ThreadFactory` that 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 already `activeTasks` running threads and `waitingTasks` tasks waiting in its queue.
    Parameters:
      `activeTasks` - maximum number of active tasks
      `waitingTasks` - maximum number of waiting tasks
      `keepAliveTime` - time until threads are cleaned up in `unit`
      `unit` - time unit
      `prefixName` - prefix of name for threads
    Returns:
      BlockingThreadPoolExecutorService.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `SemaphoredDelegatingExecutor`