void scheduleTask(List<Task> tasks, int threads) {
        ExecutorService executor = Executors.newFixedThreadPool(threads);
        CompletableFuture<Void> future = CompletableFuture.completedFuture(null);
        for (Task task : tasks) {
            future = future.thenAcceptBothAsync(scheduleTaskUtil(task, executor), (a, b) -> {}, executor);
        }
        future.thenRunAsync(() -> {System.out.println("All tasks done. Closing executor"); executor.shutdown();});
    }
Given a Task with list of its dependencies and execute method. Run the task such that dependencies are executed first.
You are given x number of threads. Increase parallelism as much as possible.
src/com/interview/multithreaded/DependencyTaskExecutor.java