How to create a completed future in java
In Java 8 you can use the built-in CompletableFuture:
Future future = CompletableFuture.completedFuture(value);
Apache Commons Lang defines similar implementation that is called ConstantFuture, you can get it by calling:
Future<T> future = ConcurrentUtils.constantFuture(T myValue);
Guava defines Futures.immediateFuture(value)
, which does the job.