@SuppressWarnings("unchecked") private <U, V> V execute(U inputParameter, ProcessDescription<U, V> processDescription, Executor executorService) throws InterruptedException, ExecutionException { if (processDescription.getThreadType().equals(ThreadType.EXECUTOR)) { FutureTask<V> task = new FutureTask<V>(() -> { return processDescription.getFunction().apply(inputParameter); }); executorService.execute(task); return task.get(); } else { return ConcurrentUtils.runCallableAndWait(() -> { return processDescription.getFunction().apply(inputParameter); }); } }