Class MultithreadingUtils
- java.lang.Object
-
- com.epam.reportportal.utils.concurrency.MultithreadingUtils
-
public class MultithreadingUtils extends java.lang.ObjectUtility class for working with multithreading in ReportPortal client. Provides methods for creating and shutting down executor services.
-
-
Constructor Summary
Constructors Constructor Description MultithreadingUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.ExecutorServicebuildExecutorService(java.lang.String namePrefix, int threadCount)Creates a fixed thread pool executor service with daemon threads and custom naming pattern.static java.util.concurrent.ExecutorServicebuildExecutorService(java.lang.String namePrefix, ListenerParameters params)Creates a fixed thread pool executor service with daemon threads using pool size from listener parameters.static voidshutdownExecutorService(java.util.concurrent.ExecutorService executorService, long duration, java.util.concurrent.TimeUnit timeUnit)Gracefully shuts down an executor service with a specified timeout.
-
-
-
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 executorthreadCount- 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 executorparams- 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 nullduration- the maximum time to wait for terminationtimeUnit- the time unit of the duration parameter, must not be null
-
-