FileDocCategorySizeDatePackage
Countdown.javaAPI DocExample657Wed Apr 19 11:23:58 BST 2000None

Countdown

public class Countdown extends Object
Simple countdown timer demo of java.util.Timer facility.

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        if (args.length != 1) {
            System.err.println("Usage: java Countdown <time in secs>");
            System.exit(1);
        }
        final Timer timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {
            int i = Integer.parseInt(args[0]);
            public void run() {
                System.out.println(i--);
                if (i< 0)
                    timer.cancel();
            }
        }, 0, 1000);