Created
July 7, 2012 02:43
-
-
Save ucheng/3064009 to your computer and use it in GitHub Desktop.
Java Timer example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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