Class AutoCloseableExecutorService

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.util.concurrent.Executor, java.util.concurrent.ExecutorService

    public class AutoCloseableExecutorService
    extends java.util.concurrent.ThreadPoolExecutor
    implements java.lang.AutoCloseable
    A ThreadPoolExecutor that can be used in a try-with-resources block.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor

        java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
    • Constructor Summary

      Constructors 
      Constructor Description
      AutoCloseableExecutorService​(int numThreads)
      A ThreadPoolExecutor that can be used in a try-with-resources block.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Shut down thread pool on close().
      • Methods inherited from class java.util.concurrent.ThreadPoolExecutor

        afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated, toString
      • Methods inherited from class java.util.concurrent.AbstractExecutorService

        invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AutoCloseableExecutorService

        public AutoCloseableExecutorService​(int numThreads)
        A ThreadPoolExecutor that can be used in a try-with-resources block.
        Parameters:
        numThreads - The number of threads to allocate.
    • Method Detail

      • close

        public void close()
        Shut down thread pool on close().
        Specified by:
        close in interface java.lang.AutoCloseable