Class ExecutorServiceHelper

java.lang.Object
com.helger.base.concurrent.ExecutorServiceHelper

@Immutable public final class ExecutorServiceHelper extends Object
Wrapper around an ExecutorService with additional helper methods.
Author:
Philip Helger
  • Method Details

    • waitUntilAllTasksAreFinished

      public static @NonNull EInterrupt waitUntilAllTasksAreFinished(@NonNull ExecutorService aES)
      Wait indefinitely on the ExecutorService until it terminates.
      Parameters:
      aES - The ExecutorService to operate on. May not be null.
      Returns:
      EInterrupt.INTERRUPTED if the executor service was interrupted while awaiting termination. Never null.
    • waitUntilAllTasksAreFinished

      public static @NonNull EInterrupt waitUntilAllTasksAreFinished(@NonNull ExecutorService aES, @Nonnegative long nTimeout, @NonNull TimeUnit eUnit)
      Wait indefinitely on the ExecutorService until it terminates.
      Parameters:
      aES - The ExecutorService to operate on. May not be null.
      nTimeout - the maximum time to wait. Must be > 0.
      eUnit - the time unit of the timeout argument. Must not be null .
      Returns:
      EInterrupt.INTERRUPTED if the executor service was interrupted while awaiting termination. Never null.
    • shutdownAndWaitUntilAllTasksAreFinished

      public static @NonNull EInterrupt shutdownAndWaitUntilAllTasksAreFinished(@NonNull ExecutorService aES)
      Call shutdown on the ExecutorService and wait indefinitely until it terminated.
      Parameters:
      aES - The ExecutorService to operate on. May not be null.
      Returns:
      EInterrupt.INTERRUPTED if the executor service was interrupted while awaiting termination. Never null.
    • shutdownAndWaitUntilAllTasksAreFinished

      public static @NonNull EInterrupt shutdownAndWaitUntilAllTasksAreFinished(@NonNull ExecutorService aES, @Nonnegative long nTimeout, @NonNull TimeUnit eUnit)
      Call shutdown on the ExecutorService and wait indefinitely until it terminated.
      Parameters:
      aES - The ExecutorService to operate on. May not be null.
      nTimeout - the maximum time to wait. Must be > 0.
      eUnit - the time unit of the timeout argument. Must not be null .
      Returns:
      EInterrupt.INTERRUPTED if the executor service was interrupted while awaiting termination. Never null.