/** * This class monitors multiple threads, starting each thread in * a prescribed order. Modify that order by rewriting the * method runTasks() to indicate the desired order of thread * execution. This scheduler does not require threads to sleep() * or do any polling of the monitor. The monitor starts threads * according to the algorithm you code in runTasks(). */ public class TaskScheduler { private int nbrOfTasks; private boolean allDone = false; private boolean[] isDone; private Task[] tasks; // The constructor instantiates the number of threads // passed to it, sets up an array to track which // threads have completed, then calls runTask(). public TaskScheduler(int nbrOfTasks) { this.nbrOfTasks = nbrOfTasks; // set up the array of threads to execute tasks = new Task[ nbrOfTasks ]; for( int i=0; i