Java Ordering Tasks Solution