public final class ExecutorServiceUtil extends Object
ExecutorServices.| Modifier and Type | Method and Description |
|---|---|
static <E> @NonNull BlockingQueue<E> |
offerFailingBlockingQueue(BlockingQueue<E> delegate)
Creates a
BlockingQueue which does not allow for non-blocking addition to the queue. |
static void |
tryGracefulShutdown(@NonNull ExecutorService executor,
long timeout,
@NonNull TimeUnit unit)
Tries to shutdown the given executor gracefully by awaiting termination for the given
timeout period.
|
static @NonNull RejectedExecutionHandler |
waitInQueueExecutionHandler()
Returns a
RejectedExecutionHandler which blocks on the ThreadPoolExecutor's
backing queue if a new thread cannot be spawned. |
public static <E> @NonNull BlockingQueue<E> offerFailingBlockingQueue(BlockingQueue<E> delegate)
BlockingQueue which does not allow for non-blocking addition to the queue.
This is useful with waitInQueueExecutionHandler() to turn force a
ThreadPoolExecutor to create as many threads as it is configured to before starting
to fill the queue.delegate - Backing blocking queue.public static @NonNull RejectedExecutionHandler waitInQueueExecutionHandler()
RejectedExecutionHandler which blocks on the ThreadPoolExecutor's
backing queue if a new thread cannot be spawned.public static void tryGracefulShutdown(@NonNull ExecutorService executor, long timeout, @NonNull TimeUnit unit)
Copyright © 2019 OpenDaylight. All rights reserved.