public class styx extends Applet implements Runnable
{
protected Thread daemon;
public synchronized void start() //Overwrites Applet.start()
{
if (daemon == null)
{
daemon = new Thread(this);
daemon.start();
}
}
public synchronized void stop() //Overwrites Applet.stop()
{
daemon.stop();
daemon = null; //Delete Thread
}
public void run() //Overwrites Runnable.run()
{
while(daemon != null)
{
try {Thread.sleep(30);} //Delay of 30 ms.
catch (InterruptedException e){ }
draw_styx(getGraphics());
}
}
...
(See full source JDK1.0.2 or full source JDK1.1.)
|