while ( updateThread != null ) { try { Thread.sleep( updateInterval ); } catch (InterruptedException e ) { return; } repaint( ); }
if ( updateThread == null ) { updateThread = new Thread(this); updateThread.start( ); }
if ( updateThread != null ) { Thread runner = updateThread; updateThread = null; // flag to quit runner.interrupt( ); // wake up if asleep }