Example #1
1
  public void run() {

    while (remainingJobs() > 0) {

      Object input = null;

      synchronized (pool) {
        while (pool.isEmpty()) {
          if (remainingJobs() == 0) {
            return;
          }
          try {
            pool.wait();
          } catch (InterruptedException e) {
          }
        }

        input = pool.remove(pool.size() - 1);

        process(input);
        jobsDone++;
      }
      // end if
    }
    // end while
  }