If tryAcquireSharedNanos() returns false, we timed out, just return immediately.

2.3.0
Brett Wooldridge 10 years ago
parent ed2fa1b513
commit 96a71da526

@ -125,11 +125,13 @@ public class ConcurrentBag<T extends IConcurrentBagEntry>
listener.addBagItem();
synchronizer.tryAcquireSharedNanos(startSeq, timeout);
if (!synchronizer.tryAcquireSharedNanos(startSeq, timeout)) {
return null;
}
timeout = originTimeout - (System.nanoTime() - startScan);
}
while (timeout > 0L);
while (timeout > 1000L); // 1000ns is the minimum resolution on many systems
return null;
}

Loading…
Cancel
Save