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 aThreadFactory
that is named, has a logging UncaughtExceptionHandler, and returns (Guava's) ListenableFuture.
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_TIMEOUT_FOR_SHUTDOWN
static TimeUnit
DEFAULT_TIMEOUT_UNIT_FOR_SHUTDOWN
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ExecutorService
newCachedThreadPool(String namePrefix, Logger logger)
Deprecated, for removal: This API element is subject to removal in a future version.UsenewListeningCachedThreadPool(String, Logger)
instead.static ListeningExecutorService
newFixedThreadPool(int size, String namePrefix, Logger logger)
static ListeningExecutorService
newListeningCachedThreadPool(String namePrefix, Logger logger)
static ListeningScheduledExecutorService
newListeningScheduledThreadPool(int corePoolSize, String namePrefix, Logger logger)
static ListeningExecutorService
newListeningSingleThreadExecutor(String namePrefix, Logger logger)
Creates a single thread executor with aThreadFactory
that uses the provided prefix for its thread names and logs uncaught exceptions with the specifiedLogger
.static ListeningScheduledExecutorService
newListeningSingleThreadScheduledExecutor(String namePrefix, Logger logger)
static ScheduledExecutorService
newScheduledThreadPool(int corePoolSize, String namePrefix, Logger logger)
Deprecated, for removal: This API element is subject to removal in a future version.static ExecutorService
newSingleThreadExecutor(String namePrefix, Logger logger)
Deprecated, for removal: This API element is subject to removal in a future version.UsenewListeningSingleThreadExecutor(String, Logger)
instead.static ScheduledExecutorService
newSingleThreadScheduledExecutor(String namePrefix, Logger logger)
Deprecated, for removal: This API element is subject to removal in a future version.static void
shutdownAndAwaitTermination(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 ListeningExecutorService newListeningSingleThreadExecutor(String namePrefix, Logger logger)
Creates a single thread executor with aThreadFactory
that 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(forRemoval=true) public static ExecutorService newSingleThreadExecutor(String namePrefix, Logger logger)
Deprecated, for removal: This API element is subject to removal in a future version.UsenewListeningSingleThreadExecutor(String, Logger)
instead.Deprecated single thread executor.
-
newFixedThreadPool
public static ListeningExecutorService newFixedThreadPool(int size, String namePrefix, Logger logger)
-
newListeningCachedThreadPool
public static ListeningExecutorService newListeningCachedThreadPool(String namePrefix, Logger logger)
-
newCachedThreadPool
@Deprecated(forRemoval=true) public static ExecutorService newCachedThreadPool(String namePrefix, Logger logger)
Deprecated, for removal: This API element is subject to removal in a future version.UsenewListeningCachedThreadPool(String, Logger)
instead.Deprecated cached thread pool executor.
-
newListeningSingleThreadScheduledExecutor
public static ListeningScheduledExecutorService newListeningSingleThreadScheduledExecutor(String namePrefix, Logger logger)
-
newSingleThreadScheduledExecutor
@Deprecated(forRemoval=true) public static ScheduledExecutorService newSingleThreadScheduledExecutor(String namePrefix, Logger logger)
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated single thread executor.
-
newListeningScheduledThreadPool
public static ListeningScheduledExecutorService newListeningScheduledThreadPool(int corePoolSize, String namePrefix, Logger logger)
-
newScheduledThreadPool
@Deprecated(forRemoval=true) public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize, String namePrefix, Logger logger)
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated scheduled executor.
-
shutdownAndAwaitTermination
public static void shutdownAndAwaitTermination(ExecutorService executorService)
-
-