Class Executors
- java.lang.Object
-
- org.opendaylight.infrautils.utils.concurrent.Executors
-
public final class Executors extends Object
Additional factory and utility methods for executors.Use this instead of
Executors, because it ensures that the returned Executor uses aThreadFactorythat is named, has a logging UncaughtExceptionHandler, and returns (Guava's) ListenableFuture.
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_TIMEOUT_FOR_SHUTDOWNstatic TimeUnitDEFAULT_TIMEOUT_UNIT_FOR_SHUTDOWN
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ExecutorServicenewCachedThreadPool(String namePrefix, org.slf4j.Logger logger)Deprecated.UsenewListeningCachedThreadPool(String, Logger)instead.static com.google.common.util.concurrent.ListeningExecutorServicenewFixedThreadPool(int size, String namePrefix, org.slf4j.Logger logger)static com.google.common.util.concurrent.ListeningExecutorServicenewListeningCachedThreadPool(String namePrefix, org.slf4j.Logger logger)static com.google.common.util.concurrent.ListeningScheduledExecutorServicenewListeningScheduledThreadPool(int corePoolSize, String namePrefix, org.slf4j.Logger logger)static com.google.common.util.concurrent.ListeningExecutorServicenewListeningSingleThreadExecutor(String namePrefix, org.slf4j.Logger logger)Creates a single thread executor with aThreadFactorythat uses the provided prefix for its thread names and logs uncaught exceptions with the specifiedLogger.static com.google.common.util.concurrent.ListeningScheduledExecutorServicenewListeningSingleThreadScheduledExecutor(String namePrefix, org.slf4j.Logger logger)static ScheduledExecutorServicenewScheduledThreadPool(int corePoolSize, String namePrefix, org.slf4j.Logger logger)Deprecated.static ExecutorServicenewSingleThreadExecutor(String namePrefix, org.slf4j.Logger logger)Deprecated.UsenewListeningSingleThreadExecutor(String, Logger)instead.static ScheduledExecutorServicenewSingleThreadScheduledExecutor(String namePrefix, org.slf4j.Logger logger)Deprecated.static voidshutdownAndAwaitTermination(ExecutorService executorService)
-
-
-
Field Detail
-
DEFAULT_TIMEOUT_FOR_SHUTDOWN
public static final long DEFAULT_TIMEOUT_FOR_SHUTDOWN
- See Also:
- Constant Field Values
-
DEFAULT_TIMEOUT_UNIT_FOR_SHUTDOWN
public static final TimeUnit DEFAULT_TIMEOUT_UNIT_FOR_SHUTDOWN
-
-
Method Detail
-
newListeningSingleThreadExecutor
public static com.google.common.util.concurrent.ListeningExecutorService newListeningSingleThreadExecutor(String namePrefix, org.slf4j.Logger logger)
Creates a single thread executor with aThreadFactorythat uses the provided prefix for its thread names and logs uncaught exceptions with the specifiedLogger.- Parameters:
namePrefix- Prefix for this executor thread nameslogger- Logger used to log uncaught exceptions- Returns:
- the newly created single-threaded Executor
-
newSingleThreadExecutor
@Deprecated public static ExecutorService newSingleThreadExecutor(String namePrefix, org.slf4j.Logger logger)
Deprecated.UsenewListeningSingleThreadExecutor(String, Logger)instead.Deprecated single thread executor.
-
newFixedThreadPool
public static com.google.common.util.concurrent.ListeningExecutorService newFixedThreadPool(int size, String namePrefix, org.slf4j.Logger logger)
-
newListeningCachedThreadPool
public static com.google.common.util.concurrent.ListeningExecutorService newListeningCachedThreadPool(String namePrefix, org.slf4j.Logger logger)
-
newCachedThreadPool
@Deprecated public static ExecutorService newCachedThreadPool(String namePrefix, org.slf4j.Logger logger)
Deprecated.UsenewListeningCachedThreadPool(String, Logger)instead.Deprecated cached thread pool executor.
-
newListeningSingleThreadScheduledExecutor
public static com.google.common.util.concurrent.ListeningScheduledExecutorService newListeningSingleThreadScheduledExecutor(String namePrefix, org.slf4j.Logger logger)
-
newSingleThreadScheduledExecutor
@Deprecated public static ScheduledExecutorService newSingleThreadScheduledExecutor(String namePrefix, org.slf4j.Logger logger)
Deprecated.Deprecated single thread executor.
-
newListeningScheduledThreadPool
public static com.google.common.util.concurrent.ListeningScheduledExecutorService newListeningScheduledThreadPool(int corePoolSize, String namePrefix, org.slf4j.Logger logger)
-
newScheduledThreadPool
@Deprecated public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize, String namePrefix, org.slf4j.Logger logger)
Deprecated.Deprecated scheduled executor.
-
shutdownAndAwaitTermination
public static void shutdownAndAwaitTermination(ExecutorService executorService)
-
-