Skip to content

Instantly share code, notes, and snippets.

@skumjava
Last active February 16, 2016 08:08
Show Gist options
  • Select an option

  • Save skumjava/e7c2672c70eff7c46e6b to your computer and use it in GitHub Desktop.

Select an option

Save skumjava/e7c2672c70eff7c46e6b to your computer and use it in GitHub Desktop.
import java.util.Timer;
import java.util.TimerTask;
public class JavaTimer {
public static void main(String[] args){
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
System.out.println("Inside Timer Task" + System.currentTimeMillis());
}
};
System.out.println("Current time" + System.currentTimeMillis());
timer.schedule(task, 10000,1000);
System.out.println("Current time" + System.currentTimeMillis());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment