Class MultithreadingUtils


  • public class MultithreadingUtils
    extends java.lang.Object
    Utility class for working with multithreading in ReportPortal client. Provides methods for creating and shutting down executor services.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.concurrent.ExecutorService buildExecutorService​(java.lang.String namePrefix, int threadCount)
      Creates a fixed thread pool executor service with daemon threads and custom naming pattern.
      static java.util.concurrent.ExecutorService buildExecutorService​(java.lang.String namePrefix, ListenerParameters params)
      Creates a fixed thread pool executor service with daemon threads using pool size from listener parameters.
      static void shutdownExecutorService​(java.util.concurrent.ExecutorService executorService, long duration, java.util.concurrent.TimeUnit timeUnit)
      Gracefully shuts down an executor service with a specified timeout.
      • Methods inherited from class java.lang.Object

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

      • MultithreadingUtils

        public MultithreadingUtils()
    • Method Detail

      • buildExecutorService

        public static java.util.concurrent.ExecutorService buildExecutorService​(java.lang.String namePrefix,
                                                                                int threadCount)
        Creates a fixed thread pool executor service with daemon threads and custom naming pattern.
        Parameters:
        namePrefix - prefix for thread names created by this executor
        threadCount - number of threads in the pool
        Returns:
        a new fixed thread pool executor service
      • buildExecutorService

        public static java.util.concurrent.ExecutorService buildExecutorService​(java.lang.String namePrefix,
                                                                                ListenerParameters params)
        Creates a fixed thread pool executor service with daemon threads using pool size from listener parameters.
        Parameters:
        namePrefix - prefix for thread names created by this executor
        params - listener parameters containing IO pool size configuration
        Returns:
        a new fixed thread pool executor service
      • shutdownExecutorService

        public static void shutdownExecutorService​(@Nonnull
                                                   java.util.concurrent.ExecutorService executorService,
                                                   long duration,
                                                   @Nonnull
                                                   java.util.concurrent.TimeUnit timeUnit)
        Gracefully shuts down an executor service with a specified timeout. If the executor service doesn't terminate within the specified time, it will be forcibly shut down. If the shutdown is interrupted, the executor service will also be forcibly shut down.
        Parameters:
        executorService - the executor service to shut down, must not be null
        duration - the maximum time to wait for termination
        timeUnit - the time unit of the duration parameter, must not be null