List of utility methods to do Thread Future
FutureCallback | callback(final CountDownLatch latch) callback return new FutureCallback<V>() { @Override public void onSuccess(final V result) { latch.countDown(); @Override public void onFailure(final Throwable t) { latch.countDown(); ... |
boolean | cancel(final Future> future) cancel return future.isDone() || future.isCancelled() || future.cancel(true);
|
boolean | cancel(Future> toCancel) cancel if (toCancel != null) { return toCancel.cancel(false); return false; |
void | cancel(List extends Future>> futures) cancel futures.forEach(f -> f.cancel(true)); |
void | cancelNullableFutures(boolean mayInterruptIfRunning, Iterable extends Future>> futures) Cancels all Futures in futures with the mayInterruptIfRunning argument. for (Future<?> f : futures) { if (f != null) { f.cancel(mayInterruptIfRunning); |
void | cancelScheduledFuture(ScheduledFuture> scheduledFuture) cancel Scheduled Future ScheduledFuture<?> future = scheduledFuture;
if (future != null && !future.isCancelled()) {
future.cancel(true);
|
void | checkTimeThresholds(long expectedMin, long expectedMax, long expectedOverhead, long start, Map check Time Thresholds long time = getMaxIn(responses) - start; assert time >= expectedMax && time < expectedMax + expectedOverhead : String .format("expectedMax %d, max %d", expectedMax, time); time = getMinIn(responses) - start; assert time >= expectedMin && time < expectedMin + expectedOverhead : String .format("expectedMin %d, min %d", expectedMin, time); time = getMaxIn(responses) - start; assert time >= expectedMax && time < expectedMax + expectedOverhead : String ... |
Future | commit(Object tx) commit return null;
|
CompletableFuture | convertFuture(Future convert Future CompletableFuture<V> brighterFuture = supplyAsync(() -> { try { return future.get(); } catch (Exception e1) { throw new RuntimeException(e1); }); return brighterFuture; ... |
CompletableFuture | createFuture() create Future return new CompletableFuture<T>(); |