Class ConcurrencyUtil

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

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

    Constructors 
    Constructor Description
    ConcurrencyUtil()  
  • Method Summary

    Modifier and Type Method Description
    static java.util.concurrent.ThreadPoolExecutor createThreadPoolExecutor​(int parallelism)
    Creates a ThreadPoolExecutor with fixed number of threads which is equal to parallelism.
    static void shutdownExecutionService​(java.util.concurrent.ExecutorService service)
    Shuts down the executor.
    static void shutdownExecutionService​(java.util.concurrent.ExecutorService service, long time, java.util.concurrent.TimeUnit timeUnit)
    Shuts down the executor.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • createThreadPoolExecutor

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

      public static void shutdownExecutionService​(java.util.concurrent.ExecutorService service) throws java.lang.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:
      java.lang.InterruptedException
    • shutdownExecutionService

      public static void shutdownExecutionService​(java.util.concurrent.ExecutorService service, long time, java.util.concurrent.TimeUnit timeUnit) throws java.lang.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:
      java.lang.InterruptedException