package thread;

abstract class Job
    implements Runnable {
  Thread t =
      new Thread(this);
  long ms = 0;

  Job(int seconds) {
    ms =
        seconds * 1000;
    t.start();
  }

  public void setName(String s) {
    t.setName(s);
  }

  public String getName() {
    return t.getName();
  }

  // for homework, write
  // set/get priority
  // get/is daemon
  abstract public void doCommand();

  public void run() {
    while (true) {
      doCommand();
      try {
        Thread.sleep(ms);
      } catch (InterruptedException e) {
      }
    }
  }

  public static void main(String args[]) {
    new Job(2) {
      public void doCommand() {
        System.out.println(
            new java.util.Date());
      }
    };
  }
}