Class LazyFutureTask<V extends @Nullable Object>

java.lang.Object
java.util.concurrent.FutureTask<V>
org.sosy_lab.common.LazyFutureTask<V>
All Implemented Interfaces:
Runnable, Future<V>, RunnableFuture<V>

public class LazyFutureTask<V extends @Nullable Object> extends FutureTask<V>
Future implementation that can be used when a task should be executed only lazily at the first time get() is called. I.e., it is not guaranteed that the task is run at all, but it is called at most once.

Execution of the task happens in the caller's thread, a little bit similar to the use of MoreExecutors.newDirectExecutorService(), however, it is executed on the thread calling get() and not on the thread calling ExecutorService.submit(Callable).

Important: Calling get(long, TimeUnit) is not supported and will always throw UnsupportedOperationException.

Canceling this future works as expected.