/** * @author lautturi.com * Java example: run task every 1 seconds in java */ import java.util.Timer; import java.util.TimerTask; public class Lautturi { public static void main(String[] args) { Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { System.out.println("Hello World!"); } }, 0, 1000);//wait 0 ms to run // execute schedule once every 1000ms //stop the timer //timer.cancel(); } }