Share Pastebin
Guest
Public paste!

caiobm

By: a guest | Apr 16th, 2009 | Syntax: Java | Size: 0.31 KB | Hits: 76 | Expires: Never
Copy text to clipboard
  1. public class PrintTask extends java.util.TimerTask {
  2.         private int counter;
  3.  
  4.         public PrintTask() {
  5.         }
  6.        
  7.         public void run() {
  8.                 System.out.println(counter++);
  9.         }
  10.        
  11.         public static void main(String[] args) {
  12.                 java.util.Timer tim = new java.util.Timer();
  13.                 tim.scheduleAtFixedRate(new PrintTask(), 0, 1000);
  14.         }
  15. }