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, org.slf4j.Logger logger)
Deprecated, for removal: This API element is subject to removal in a future version.UsenewListeningCachedThreadPool(String, Logger)
instead.static com.google.common.util.concurrent.ListeningExecutorService
newFixedThreadPool(int size, String namePrefix, org.slf4j.Logger logger)
static com.google.common.util.concurrent.ListeningExecutorService
newListeningCachedThreadPool(String namePrefix, org.slf4j.Logger logger)
static com.google.common.util.concurrent.ListeningScheduledExecutorService
newListeningScheduledThreadPool(int corePoolSize, String namePrefix, org.slf4j.Logger logger)
static com.google.common.util.concurrent.ListeningExecutorService
newListeningSingleThreadExecutor(String namePrefix, org.slf4j.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 com.google.common.util.concurrent.ListeningScheduledExecutorService
newListeningSingleThreadScheduledExecutor(String namePrefix, org.slf4j.Logger logger)
static ScheduledExecutorService
newScheduledThreadPool(int corePoolSize, String namePrefix, org.slf4j.Logger logger)
Deprecated, for removal: This API element is subject to removal in a future version.static ExecutorService
newSingleThreadExecutor(String namePrefix, org.slf4j.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, org.slf4j.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 com.google.common.util.concurrent.ListeningExecutorService newListeningSingleThreadExecutor(String namePrefix, org.slf4j.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, org.slf4j.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 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(forRemoval=true) public static ExecutorService newCachedThreadPool(String namePrefix, org.slf4j.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 com.google.common.util.concurrent.ListeningScheduledExecutorService newListeningSingleThreadScheduledExecutor(String namePrefix, org.slf4j.Logger logger)
-
newSingleThreadScheduledExecutor
@Deprecated(forRemoval=true) public static ScheduledExecutorService newSingleThreadScheduledExecutor(String namePrefix, org.slf4j.Logger logger)
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated single thread executor.
-
newListeningScheduledThreadPool
public static com.google.common.util.concurrent.ListeningScheduledExecutorService newListeningScheduledThreadPool(int corePoolSize, String namePrefix, org.slf4j.Logger logger)
-
newScheduledThreadPool
@Deprecated(forRemoval=true) public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize, String namePrefix, org.slf4j.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)
-
-