Class ExecutorsFactory


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

      • newFixedDaemonExecutor

        @NotNull
        public static ExecutorService newFixedDaemonExecutor​(@NotNull
                                                             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 ExecutorService newFixedDaemonExecutor​(@NotNull
                                                             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 ExecutorService newFixedExecutor​(@NotNull
                                                       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 ScheduledExecutorService newFixedScheduledDaemonExecutor​(@NotNull
                                                                               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 ScheduledExecutorService newFixedScheduledExecutor​(@NotNull
                                                                         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 ExecutorService newDaemonExecutor​(@NotNull
                                                        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 ExecutorService newExecutor​(@NotNull
                                                  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 ExecutorService newSingleThreadedExecutor​(@NotNull
                                                                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