Java Utililty Methods Thread Future

List of utility methods to do Thread Future

  1. HOME
  2. Java
  3. T
  4. Thread Future

Description

The list of methods to do Thread Future are organized into topic(s).

Method

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> futures)
cancel
futures.forEach(f -> f.cancel(true));
void cancelNullableFutures(boolean mayInterruptIfRunning, Iterable> 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> responses)
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 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>();


AltStyle によって変換されたページ (->オリジナル) /