// HardLoop5 package Bugs; import java.applet.*; import java.awt.*; public class HardLoop5 extends Applet implements Runnable { boolean pleaseStop; int i = 0; // Called when the applet should paint itself. public void paint( Graphics graphics ) { graphics.setColor( Color.black ); graphics.drawString( Integer.toString( i ), 50, 50 ); } // Called when the applet should start itself. public void start() { pleaseStop = false; (new Thread( this )).start(); } // Called when the applet should stop itself. public void stop() { pleaseStop = true; } // This is the part of Runnable that we implement - the // routine that gets called when the thread is started. public void run() { for ( i = 0; ! pleaseStop; ++i ) { repaint(); Thread.yield(); } } }