Class ConcurrencyUtil

java.lang.Object
org.jgrapht.util.ConcurrencyUtil

public class ConcurrencyUtil extends Object
Utility class to manage creation and shutting down instance of the ThreadPoolExecutor.
  • Constructor Details

    • ConcurrencyUtil

      public ConcurrencyUtil()
  • Method Details

    • createThreadPoolExecutor

      public static ThreadPoolExecutor createThreadPoolExecutor(int parallelism)
      Creates a ThreadPoolExecutor with fixed number of threads which is equal to parallelism.
      Parameters:
      parallelism - number of threads for the executor
      Returns:
      created executor
    • shutdownExecutionService

      public static void shutdownExecutionService(ExecutorService service) throws InterruptedException
      Shuts down the executor. This operation puts the service into a state where every subsequent task submitted to the service will be rejected. This method calls shutdownExecutionService(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 the executor. This operation puts the service into a state where every subsequent task submitted to the service will be rejected.
      Parameters:
      service - service to be shut down
      time - period of time to wait for the completion of the termination
      timeUnit - time duration granularity for the provided time
      Throws:
      InterruptedException