Java tutorial
import java.util.Timer; import java.util.TimerTask; class MyTimerTask extends TimerTask { public void run() { System.out.println("Timer task executed."); } } public class Main { public static void main(String[] args) { TimerTask tasknew = new MyTimerTask(); Timer timer = new Timer(); timer.scheduleAtFixedRate(tasknew, 500, 1000); } // this method performs the task public void run() { System.out.println("working at fixed rate delay"); } }