public V getResult(I item) throws InterruptedException, ExecutionException { Future<V> future = results.get(item.getKey()); if (future == null) { return null; } else { return future.get(); } }
public void add(I item) { if (allItems.putIfAbsent(item.getKey(), item) == null) { submitLock.lock(); try { pending.add(item); } finally { submitLock.unlock(); } } }
@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(); } }