Advertisement
zachdyer

Java: Timer

May 28th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. //Main Class
  2. import java.util.Timer;
  3. import java.util.TimerTask;
  4.  
  5.  
  6. public class Java{
  7.    
  8.     public static int count = 0;
  9.    
  10.     public static void main(String args[]){
  11.         Timer timer = new Timer();
  12.        
  13.         //Timer will fire every second
  14.         timer.schedule(new TimerTask(){
  15.             @Override
  16.             public void run(){
  17.                 count++;
  18.                 System.out.println("Scheduled timer " + count);
  19.             }
  20.         }, 1000, 1000);
  21.        
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement