public static ExecutorService blocksOnFirstCallFromCallableOfType(final ExecutorService delegate, final Class<? extends Callable> type) { return new ForwardingExecutorService() { private boolean firstCall = true; @Override protected ExecutorService delegate() { return delegate; } @Override public <T> Future<T> submit(Callable<T> task) { if (task.getClass().equals(type) && firstCall) { firstCall = false; try { return Futures.immediateFuture(task.call()); } catch (Exception e) { throw new RuntimeException(e); } } return super.submit(task); } }; }