Scheduling a Timer Task to Run at a Certain Time
import java.sql.Date; import java.util.Timer; import java.util.TimerTask; public class Main { public static void main(String[] argv) throws Exception { Date timeToRun = new Date(System.currentTimeMillis() + numberOfMillisecondsInTheFuture); Timer timer = new Timer(); timer.schedule(new TimerTask() { public void run() { System.out.println("doing"); } }, timeToRun); } }