A call to sweep(), although protected by the lock for concurrent calls to reserve(), may be concurrent with remove(Entry).
remove(Entry) in turn calls entries.remove(Object), so that the concurrent iteration in sweep() over entries fails with an ArrayIndexOutOfBoundsException.
Now using the bulk entries.removeIf(Predicate) method in sweep(), so that sweeping is atomic with respect to entries.remove(Object).
A call to
sweep()
, although protected by the lock for concurrent calls toreserve()
, may be concurrent withremove(Entry)
.remove(Entry)
in turn callsentries.remove(Object)
, so that the concurrent iteration insweep()
overentries
fails with anArrayIndexOutOfBoundsException
.Now using the bulk
entries.removeIf(Predicate)
method insweep()
, so that sweeping is atomic with respect toentries.remove(Object)
.