Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Timer;
import java.util.TimerTask;

public class Main {
    Timer timer;

    public Main(int seconds) {
        timer = new Timer();
        timer.schedule(new ToDoTask(), seconds * 1000);
    }

    class ToDoTask extends TimerTask {
        public void run() {
            System.out.println("working");
            timer.cancel();
        }
    }

    public static void main(String args[]) {
        new Main(5);
    }
}