// @topic T11724 2D Graphics demo 01 // @brief class <tt>ThreadPainter</tt> implements <tt>Runnable</tt> package shopsimulation; public class ThreadPainter implements Runnable { public static final int SLEEP_TIMEOUT = 1000 / 24; // 24 fps ViewSimulation mWindow; // constructors public ThreadPainter( ViewSimulation window ) { mWindow = window; } @Override public void run() { for(;;) { // forever... try { // ask EDT thread to repaint itself java.awt.EventQueue.invokeLater(new Runnable() { public void run() { mWindow.repaint(); } }); // go to sleep for a period of time Thread.sleep( SLEEP_TIMEOUT ); } catch (InterruptedException ie) { } } } }//class ThreadPainter