package ballWorlds.framework; import ballWorlds.Ball; /** * TODO Put here a description of this class: what its objects are and/or do. * @author mutchler. Created Sep 20, 2009. */ public class BallRunner implements Runnable { private Ball ballToRun; private int timeToSleepBetweenActs = 5; // milliseconds /** * Milliseconds to sleep between repaints of the World and its Balls. */ public static final int TIME_TO_SLEEP_BETWEEN_REPAINTS = 10; // milliseconds /** * FIXME * @param worldView * The WorldView that this WorldDrawer repeatedly asks to * repaint. */ public BallRunner(Ball ballToRun) { this.ballToRun = ballToRun; new Thread(this).start(); } /** * Repeatedly asks this WorldDrawer's WorldView to repaint (i.e., to redraw * its associated World and Balls). */ public void run() { while (true) { try { this.ballToRun.act(); Thread.sleep(this.timeToSleepBetweenActs); } catch (InterruptedException exception) { // If you can't sleep, no problem -- just continue. } } } }