Producers { public static <T> ListenableFuture<T> submitToExecutor(Callable<T> callable, Executor executor) { ListenableFutureTask<T> future = ListenableFutureTask.create(callable); executor.execute(future); return future; } private  Producers(); static ListenableFuture<Produced<T>> createFutureProduced(ListenableFuture<T> future); static ListenableFuture<Set<T>> createFutureSingletonSet(ListenableFuture<T> future); static ListenableFuture<T> submitToExecutor(Callable<T> callable, Executor executor); static Producer<T> producerFromProvider(final Provider<T> provider);  }
@Test public void submitToExecutor() throws Exception { ListenableFuture<Integer> future = Producers.submitToExecutor(new Callable<Integer>() { @Override public Integer call() { return 42; } }, MoreExecutors.directExecutor()); assertThat(future.isDone()).isTrue(); assertThat(future.get()).isEqualTo(42); }