Class ExecutorsFactory


  • public class ExecutorsFactory
    extends java.lang.Object
    Factory for various thread pool executors. Should be used instead of standard Java Executors class.
    Since:
    8.1.2
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.concurrent.ExecutorService newDaemonExecutor​(java.lang.String threadNamePrefix)
      Creates not fixed thread pool executor with daemon threads.
      static java.util.concurrent.ExecutorService newExecutor​(java.lang.String threadNamePrefix)
      Creates not fixed thread pool executor with non daemon threads.
      static java.util.concurrent.ExecutorService newFixedDaemonExecutor​(java.lang.String threadNamePrefix, int poolSize)
      Creates fixed thread pool executor of specified size with daemon threads.
      static java.util.concurrent.ExecutorService newFixedDaemonExecutor​(java.lang.String threadNamePrefix, int minPoolSize, int maxPoolSize, int maxQueueSize)
      Creates thread pool executor with specified number of minimum and maximum daemon threads.
      static java.util.concurrent.ExecutorService newFixedExecutor​(java.lang.String threadNamePrefix, int poolSize)
      Creates fixed thread pool executor of specified size with non daemon threads.
      static java.util.concurrent.ScheduledExecutorService newFixedScheduledDaemonExecutor​(java.lang.String threadNamePrefix, int poolSize)
      Creates fixed scheduled thread pool executor of specified size with daemon threads.
      static java.util.concurrent.ScheduledExecutorService newFixedScheduledExecutor​(java.lang.String threadNamePrefix, int poolSize)
      Creates fixed scheduled thread pool executor of specified size with non daemon threads.
      static java.util.concurrent.ExecutorService newSingleThreadedExecutor​(java.lang.String threadNamePrefix)
      Creates single-threaded pool executor with non daemon threads.
      • Methods inherited from class java.lang.Object

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

      • ExecutorsFactory

        public ExecutorsFactory()
    • Method Detail

      • newFixedDaemonExecutor

        @NotNull
        public static java.util.concurrent.ExecutorService newFixedDaemonExecutor​(@NotNull
                                                                                  java.lang.String threadNamePrefix,
                                                                                  int poolSize)
        Creates fixed thread pool executor of specified size with daemon threads.
        Parameters:
        threadNamePrefix - prefix for thread names
        poolSize - size of the thread pool
        Returns:
        new thread pool
        Since:
        8.1.2
      • newFixedDaemonExecutor

        @NotNull
        public static java.util.concurrent.ExecutorService newFixedDaemonExecutor​(@NotNull
                                                                                  java.lang.String threadNamePrefix,
                                                                                  int minPoolSize,
                                                                                  int maxPoolSize,
                                                                                  int maxQueueSize)
        Creates thread pool executor with specified number of minimum and maximum daemon threads. This executor also uses fixed size queue.
        Parameters:
        threadNamePrefix - thread name prefix
        minPoolSize - minimum number of threads to keep in pool
        maxPoolSize - maximum number of threads
        maxQueueSize - maximum size of the queue
        Returns:
        see above
        Since:
        2018.2.1
      • newFixedExecutor

        @NotNull
        public static java.util.concurrent.ExecutorService newFixedExecutor​(@NotNull
                                                                            java.lang.String threadNamePrefix,
                                                                            int poolSize)
        Creates fixed thread pool executor of specified size with non daemon threads.
        Parameters:
        threadNamePrefix - prefix for thread names
        poolSize - size of the thread pool
        Returns:
        new thread pool
        Since:
        8.1.2
      • newFixedScheduledDaemonExecutor

        @NotNull
        public static java.util.concurrent.ScheduledExecutorService newFixedScheduledDaemonExecutor​(@NotNull
                                                                                                    java.lang.String threadNamePrefix,
                                                                                                    int poolSize)
        Creates fixed scheduled thread pool executor of specified size with daemon threads.
        Parameters:
        threadNamePrefix - prefix for thread names
        poolSize - size of the thread pool
        Returns:
        new thread pool
        Since:
        8.1.2
      • newFixedScheduledExecutor

        @NotNull
        public static java.util.concurrent.ScheduledExecutorService newFixedScheduledExecutor​(@NotNull
                                                                                              java.lang.String threadNamePrefix,
                                                                                              int poolSize)
        Creates fixed scheduled thread pool executor of specified size with non daemon threads.
        Parameters:
        threadNamePrefix - prefix for thread names
        poolSize - size of the thread pool
        Returns:
        new thread pool
        Since:
        8.1.2
      • newDaemonExecutor

        @NotNull
        public static java.util.concurrent.ExecutorService newDaemonExecutor​(@NotNull
                                                                             java.lang.String threadNamePrefix)
        Creates not fixed thread pool executor with daemon threads.
        Parameters:
        threadNamePrefix - prefix for thread names
        Returns:
        new thread pool
        Since:
        8.1.2
      • newExecutor

        @NotNull
        public static java.util.concurrent.ExecutorService newExecutor​(@NotNull
                                                                       java.lang.String threadNamePrefix)
        Creates not fixed thread pool executor with non daemon threads.
        Parameters:
        threadNamePrefix - prefix for thread names
        Returns:
        new thread pool
        Since:
        8.1.2
      • newSingleThreadedExecutor

        @NotNull
        public static java.util.concurrent.ExecutorService newSingleThreadedExecutor​(@NotNull
                                                                                     java.lang.String threadNamePrefix)
        Creates single-threaded pool executor with non daemon threads.
        Similar to Executors.newSingleThreadExecutor(), tasks are guaranteed to execute sequentially, and no more than one task will be active at any given time, unless number of threads is increased explicitly
        Parameters:
        threadNamePrefix - prefix for thread names
        Returns:
        new thread pool
        Since:
        2018.1