Class Archive.ExtractorExecutorHolder

  • Enclosing class:
    Archive

    private static final class Archive.ExtractorExecutorHolder
    extends java.lang.Object
    Class to ensure the lazy initialization of the ThreadPoolExecutor upon first usage.

    Using a cached thread pool executor is more efficient and creating a new thread for each extraction. The total number of threads will only increase if there are tasks on its queue and all current threads are busy. If there are available threads, those will be reused instead of a new one being created.

    Configuration options:

    • To avoid the possibility of too many simultaneous active threads being started, the maximum number of threads can be configured through the junrar.extractor.max-threads system property. The default maximum number of threads is unbounded.
    • The keep alive time can be configured through the junrar.extractor.thread-keep-alive-seconds system property. The default is 5s.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.concurrent.ExecutorService cachedExecutorService
      Equivalent to Executors.newCachedThreadPool(), but customizable through system properties.
      private static java.util.concurrent.atomic.AtomicLong threadIndex  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static int getMaxThreads()  
      private static int getThreadKeepAlive()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • threadIndex

        private static final java.util.concurrent.atomic.AtomicLong threadIndex
      • cachedExecutorService

        private static final java.util.concurrent.ExecutorService cachedExecutorService
        Equivalent to Executors.newCachedThreadPool(), but customizable through system properties.
    • Constructor Detail

      • ExtractorExecutorHolder

        private ExtractorExecutorHolder()
    • Method Detail

      • getMaxThreads

        private static int getMaxThreads()
      • getThreadKeepAlive

        private static int getThreadKeepAlive()