Ejemplo n.º 1
0
  /**
   * Create a new Job that can be canceled.
   *
   * @param jobName the name of the Job
   * @param workerThread the thread on which this job runs
   */
  public static Progress createJob(String jobID, String jobName, Thread workerThread) {
    Progress job = new Job(jobID, jobName, workerThread);
    jobs.add(job);

    log.debug("job starting: {}", job.getJobName());

    return job;
  }
Ejemplo n.º 2
0
  /** Inform the listeners that a title has changed. */
  protected static void fireWorkProgressed(Progress job) {
    final WorkEvent ev = new WorkEvent(job);

    // We ought only to tell listeners about jobs that are in our
    // list of jobs so we need to fire before delete.
    for (WorkListener worker : listeners) {
      worker.workProgressed(ev);
    }

    // Do we need to remove the job? Note that the section above will
    // probably execute after this so we will be firing events for jobs
    // that are no longer in our list of jobs. ho hum.
    if (job.isFinished()) {
      log.debug("job finished: {}", job.getJobName());
      jobs.remove(job);
    }
  }