Skip to main content

Posts

Showing posts with the label map

java: concurrent collections

I'm trying to find one or more concurrent collections to use that I can implement the following behavior (the names are contrived for analogy purposes): /** * Acts as a broker for a concurrent hash map that stores its keys in order * of submission. At shipping time, the concurrent map is "sealed" * (picture a truck with its cargo door being closed) * and its contents presented as an immutable map, and is replaced * by a new concurrent map ready to accept values. * * Consumers of this class that submit information to it, are expected to * know that this contains a concurrent collection, and should use the * compareAndSet paradigm, e.g. the following: * * LoadingDock loadingDock = ... * boolean done = false; * while (!done) * { * V oldValue = loadingDock.get(); * V newValue = computeNewValue(oldValue, otherInformation); * if (oldValue == null) * done = loadingDock.putIfAbsent(newValue) == null; * else * done = loadingDock.replac