java.lang.Object
org.jgrapht.util.ConcurrencyUtil
Utility class to manage creation and shutting down instance of the
ThreadPoolExecutor.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ThreadPoolExecutorcreateThreadPoolExecutor(int parallelism) Creates aThreadPoolExecutorwith fixed number of threads which is equal toparallelism.static voidshutdownExecutionService(ExecutorService service) Shuts down theexecutor.static voidshutdownExecutionService(ExecutorService service, long time, TimeUnit timeUnit) Shuts down theexecutor.
-
Constructor Details
-
ConcurrencyUtil
public ConcurrencyUtil()
-
-
Method Details
-
createThreadPoolExecutor
Creates aThreadPoolExecutorwith fixed number of threads which is equal toparallelism.- Parameters:
parallelism- number of threads for the executor- Returns:
- created executor
-
shutdownExecutionService
Shuts 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:
InterruptedException
-
shutdownExecutionService
public static void shutdownExecutionService(ExecutorService service, long time, TimeUnit timeUnit) throws InterruptedException Shuts 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:
InterruptedException
-