public static void main(String args[]) {
        DependencyTaskExecutor taskExecutor = new DependencyTaskExecutor();
        SimpleSleepTask a = new SimpleSleepTask("a", 2000);
        SimpleSleepTask b = new SimpleSleepTask("b", 4000);
        SimpleSleepTask c = new SimpleSleepTask("c", 6000);
        SimpleSleepTask d = new SimpleSleepTask("d", 3000);
        SimpleSleepTask x = new SimpleSleepTask("x", 4000);
        SimpleSleepTask y = new SimpleSleepTask("y", 6000);
        SimpleSleepTask z = new SimpleSleepTask("z", 3000);

        d.addDependency(b);
        d.addDependency(c);
        c.addDependency(a);
        b.addDependency(a);
        x.addDependency(y);
        x.addDependency(z);
        y.addDependency(a);
        taskExecutor.scheduleTask(Lists.newArrayList(a, b, c, d, x, y, z), 4);
    }
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