if you are using threads:
import java.applet.*;
import java.awt.*;
public class TimerTest extends Applet implements Runnable
{
final Thread timer;
final int cycletime = 1000;
public void init() {
setSize(500,500);
timer = new Thread(this);
timer.start();
}
public void run() {
while (true) {
// Do things here
try {
timer.sleep(cycletime);
}
catch (InterruptedException ie) {
System.out.println("ERROR sleeping");
}
}
}
}
I prefer Threads, they're easier.
to stop the above Thread: timer.stop() (deprecated) or timer = null