- java.lang.Object
-
- org.jgrapht.util.ConcurrencyUtil
-
public class ConcurrencyUtil extends java.lang.ObjectUtility class to manage creation and shutting down instance of theThreadPoolExecutor.
-
-
Constructor Summary
Constructors Constructor Description ConcurrencyUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.ThreadPoolExecutorcreateThreadPoolExecutor(int parallelism)Creates aThreadPoolExecutorwith fixed number of threads which is equal toparallelism.static voidshutdownExecutionService(java.util.concurrent.ExecutorService service)Shuts down theexecutor.static voidshutdownExecutionService(java.util.concurrent.ExecutorService service, long time, java.util.concurrent.TimeUnit timeUnit)Shuts down theexecutor.
-
-
-
Method Detail
-
createThreadPoolExecutor
public static java.util.concurrent.ThreadPoolExecutor createThreadPoolExecutor(int parallelism)
Creates aThreadPoolExecutorwith fixed number of threads which is equal toparallelism.- Parameters:
parallelism- number of threads for the executor- Returns:
- created executor
-
shutdownExecutionService
public static void shutdownExecutionService(java.util.concurrent.ExecutorService service) throws java.lang.InterruptedExceptionShuts down theexecutor. This operation puts theserviceinto a state where every subsequent task submitted to theservicewill be rejected. This method callsshutdownExecutionService(ExecutorService, long, TimeUnit)with $time = Long.MAX_VALUE$ and $timeUnit = TimeUnit.MILLISECONDS$.- Parameters:
service- service to be shut down- Throws:
java.lang.InterruptedException
-
shutdownExecutionService
public static void shutdownExecutionService(java.util.concurrent.ExecutorService service, long time, java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedExceptionShuts down theexecutor. This operation puts theserviceinto a state where every subsequent task submitted to theservicewill be rejected.- Parameters:
service- service to be shut downtime- period of time to wait for the completion of the terminationtimeUnit- time duration granularity for the providedtime- Throws:
java.lang.InterruptedException
-
-