コード例 #1
0
  /** sets a flag to stop this task thread. */
  public void stopMe() {
    if (logger.isInfoEnabled()) {
      logger.info("interrupting ");
    }

    this.interrupt();

    SystemProperties props = SystemProperties.instance();
    int shutdown_time = props.getPropertyAsInt(Constants.THREADPOOL_SHUTDOWN_WAIT_TIME);

    if (logger.isTraceEnabled()) {
      logger.trace("sleeping for [" + shutdown_time + "] msecs");
    }

    try {
      // I need to put myself to sleep for awhile to give the
      // other threads a chance to stop themselves nicely.
      Thread.sleep(shutdown_time);
    } catch (InterruptedException ex) {

      if (logger.isInfoEnabled()) {
        logger.info("interrupted exception: " + ex.getMessage());
      }
    }

    v_stop_me = true;
  }
コード例 #2
0
  /* (non-Javadoc)
   * @see java.lang.Thread#start()
   */
  @Override
  public void start() {

    if (!v_stop_me) {
      if (logger.isTraceEnabled()) {
        logger.trace("launching thread.");
      }

      super.start();

      try {

        SystemProperties props = SystemProperties.instance();
        int start_time = props.getPropertyAsInt(Constants.THREADPOOL_START_UP_TIME);

        if (logger.isTraceEnabled()) {
          logger.trace("sleeping for [" + start_time + "] msecs");
        }

        // I need to put myself to sleep for awhile to give the
        // other thread a chance to start nicely.
        Thread.sleep(start_time);
      } catch (InterruptedException ex) {

        if (logger.isInfoEnabled()) {
          logger.info("interrupted exception: " + ex.getMessage());
        }

        v_stop_me = true;
      }

      if (logger.isTraceEnabled()) {
        logger.trace("constructed.");
      }
    }
  }