@ApiStatus.Internal public final class Concurrency extends Object
Concurrency class.
| Constructor and Description |
|---|
Concurrency() |
| Modifier and Type | Method and Description |
|---|---|
static <A,B> B |
combine(A a,
B b)
combine.
|
static <V> CompletableFuture<V> |
failedFuture(Throwable error)
failedFuture.
|
static <V> CompletableFuture<V> |
failedFuture(Throwable error,
Executor executor)
failedFuture.
|
static int |
getCorePoolSize(Executor executor)
Retrieve the core pool size of an executor (if available)
|
static boolean |
shutdown(ExecutorService executorService)
Shutdown an
ExecutorService the right way. |
static boolean |
shutdown(ExecutorService executorService,
int timeout,
TimeUnit timeUnit)
Shutdown an
ExecutorService the right way. |
static void |
sleepUninterrupted(int milliseconds)
Sleep without interruption
|
static <V> CompletionStage<V> |
wrap(CompletableFuture<V> future)
wrap.
|
public static <V> CompletionStage<V> wrap(CompletableFuture<V> future)
wrap.
V - a V classfuture - a CompletableFuture objectCompletionStage objectpublic static <A,B> B combine(A a,
B b)
combine.
A - a A classB - a B classa - a A objectb - a B objectpublic static <V> CompletableFuture<V> failedFuture(Throwable error)
failedFuture.
V - a V classerror - a Throwable objectCompletableFuture objectpublic static <V> CompletableFuture<V> failedFuture(Throwable error, Executor executor)
failedFuture.
V - a V classerror - a Throwable objectexecutor - a Executor objectCompletableFuture objectpublic static boolean shutdown(ExecutorService executorService)
ExecutorService the right way. This uses the default timeout parameters.executorService - The ExecutorService to shutdowntrue if the ExecutorService shutdown successfully false if executor service is null, timeout has expired or shutdown was interruptedpublic static boolean shutdown(ExecutorService executorService, int timeout, TimeUnit timeUnit)
ExecutorService the right way. This method blocks if there are still tasks running in the executor.executorService - The ExecutorService to shutdowntimeout - The timeout value to wait for a successful terminationtimeUnit - The TimeUnit of the timeout valuetrue if the ExecutorService shutdown successfully false if executor service is null, timeout has expired or shutdown was interruptedpublic static void sleepUninterrupted(int milliseconds)
Sleep without interruption
milliseconds - The number of milliseconds to sleepCopyright © 2016–2024. All rights reserved.