Class ExecutorUtils


  • public final class ExecutorUtils
    extends java.lang.Object
    Utilities for executors and sizing them.
    Since:
    1.9.5
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.concurrent.Executor DIRECT_EXECUTOR
      Shared instance of "direct executor".
    • Constructor Summary

      Constructors 
      Constructor Description
      ExecutorUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.concurrent.Executor executor​(int size, java.lang.String namePrefix)
      Returns DIRECT_EXECUTOR or result of threadPool(int, String) depending on value of size parameter.
      static void shutdown​(java.util.concurrent.Executor executor)
      To be used with result of executor(int, String) method, shuts down instance if it is ExecutorService.
      static int threadCount​(RepositorySystemSession session, int defaultValue, java.lang.String... keys)
      Retrieves and validates requested thread count based on session and specified keys, or if none provided, the provided default value.
      static java.util.concurrent.ExecutorService threadPool​(int poolSize, java.lang.String namePrefix)
      Creates new thread pool ExecutorService.
      • Methods inherited from class java.lang.Object

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

      • DIRECT_EXECUTOR

        public static final java.util.concurrent.Executor DIRECT_EXECUTOR
        Shared instance of "direct executor".
    • Constructor Detail

      • ExecutorUtils

        public ExecutorUtils()
    • Method Detail

      • threadPool

        public static java.util.concurrent.ExecutorService threadPool​(int poolSize,
                                                                      java.lang.String namePrefix)
        Creates new thread pool ExecutorService. The poolSize parameter but be greater than 1.
      • executor

        public static java.util.concurrent.Executor executor​(int size,
                                                             java.lang.String namePrefix)
        Returns DIRECT_EXECUTOR or result of threadPool(int, String) depending on value of size parameter.
      • shutdown

        public static void shutdown​(java.util.concurrent.Executor executor)
        To be used with result of executor(int, String) method, shuts down instance if it is ExecutorService.