if ((firstKey + secondKey) % numThreads != id) {
continue;
}
// Drain asynchronously
outstanding.incrementAndGet();
final IntegerBuffer toDrain = map.get(secondKey);
final int first = firstKey;
final int second = secondKey;
synchronized (toDrain) {
map.put(secondKey, new IntegerBuffer(BUFFER_CAPACITY));
}
parallelExecutor.submit(new Runnable() { public void run() {
try {
int[] d = toDrain.toIntArray();
Arrays.sort(d);
DiscreteDistribution dist = new DiscreteDistribution(d);
mergeWith(first, second, dist);
} catch (Exception err ) {
err.printStackTrace();