コード例 #1
0
 public V getResult(I item) throws InterruptedException, ExecutionException {
   Future<V> future = results.get(item.getKey());
   if (future == null) {
     return null;
   } else {
     return future.get();
   }
 }
コード例 #2
0
 public void add(I item) {
   if (allItems.putIfAbsent(item.getKey(), item) == null) {
     submitLock.lock();
     try {
       pending.add(item);
     } finally {
       submitLock.unlock();
     }
   }
 }
コード例 #3
0
 @Override
 protected void done() {
   super.done();
   results.put(item.getKey(), this);
   submitLock.lock();
   try {
     outstanding.remove(item);
     if (submitWork() == 0 && outstanding.isEmpty()) {
       submitCondition.signal();
     }
   } finally {
     submitLock.unlock();
   }
 }