import java.util.Vector; /* * The clock admin can control an arbitrary number of * RoundClocks. The admin sleeps for 1/4 second * between each update cycle. * * The ClockAdmin implements the Runnable interface, and can * therefore run in its own thread. */ public class ClockAdmin implements Runnable{ // We use a vector to hold the clocks. Vector clocks = new Vector(); /* * Adds a clock to the collection of clocks. */ public void addClock(RoundClock clock){ clocks.addElement(clock); } /* * This method should conatain an infinite loop. Within * the loop you should place the instructions to * update the clocks. */ public void run(){ while(true){ for(int i=0 ; i < clocks.size() ; i++){ RoundClock clock = (RoundClock) clocks.elementAt(i); clock.updateClock(); } // The clock admin sleeps for 0.25 seconds. I.e. we redraw // approximately 4 times every second. try{ Thread.sleep(250); } catch (InterruptedException e){} } } }