I just tested my implementation, and of course, you are right: Since Future
is not blocking and returns immediately, the synchronized
has virtually no effect.
But I don’t really understand your proposal: Why would the map of instances need to be an AtomicReference
and why would it be in the class rather than in the object?