Advertisement
Guest User

Timer

a guest
Nov 22nd, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. class TimerEx {
  2. public static void main(String args[]) {
  3. Timer timer;
  4. timer = new Timer();
  5.  
  6. TimerTask task = new TimerTask() {
  7. int tic=0;
  8.  
  9. @Override
  10. public void run()
  11. {
  12. if (tic%2==0)
  13. System.out.println("TIC");
  14. else
  15. System.out.println("TOC");
  16. tic++;
  17. }
  18. };
  19. // Started from 10 milis, then i launch it every 10000
  20. timer.schedule(task, 10, 1000);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement