示例#1
0
  public void run() {
    boolean timeoutIsReached = false;
    logger.info("Starting process with timeout=" + timeout + " s");

    try {
      int elapsedTimeInSecond = 0;
      while ((elapsedTimeInSecond < timeout) && (isRunning == true)) {
        sleep(StreamListener.PRINTING_PERIOD_IN_MILLIS);
        elapsedTimeInSecond++;
      }
      timeoutIsReached = true;
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    if (timeoutIsReached) {
      logger.info("Ending process with timeout=" + timeout + " s");
      listener.onTimeout();
    } else {
      logger.info("Ending process upon InterruptedException");
    }
    logger.debug("ProcessTimer: end of run()");
  }