Code example for PriorityBlockingQueue

Methods: add

0
    } 
    try { 
      // Future.get() is a blocking call 
      O result = submits.get(processorId).get();
      QueueItem<O> resultItem = new QueueItem<O>(result, submitIds[processorId]);
      outputQueue.add(resultItem);
      submits.set(processorId, null);
 
    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (ExecutionException e) {
      e.printStackTrace();
    } 
  } 
 
  /** 
   * Waits for all active processes to finish, then returns true only if all 
   * results have been returned via calls to next(). 
   * 
   * @return True on successful shutdown, false otherwise. 
   */