Skip to content

Instantly share code, notes, and snippets.

@ucheng
Created July 7, 2012 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ucheng/3064009 to your computer and use it in GitHub Desktop.
Save ucheng/3064009 to your computer and use it in GitHub Desktop.
Java Timer example
public class Main {
public static void main(String[] args) {
Timer timer = new Timer();
ShowCurrentTimeTask task = new ShowCurrentTimeTask();
timer.scheduleAtFixedRate(task, 0, 2000);
}
static class ShowCurrentTimeTask extends TimerTask {
@Override
public void run() {
System.out.println(System.currentTimeMillis());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment