Next we'll look at the getForUpdate(Object key)
and getAllForUpdate(List keys)
methods. These methods present us with the notion that the get(Object key)
and getAll(List keys)
methods may not get an object that allows updates. This isn't the case. These methods offer different locking semantics than the get
methods on the objects they return. On the surface, the getForUpdate(Object key)
and getAllForUpdate(List keys)
methods behave like their non-ForUpdate counterparts. The getForUpdate(Object key)
and getAllForUpdate(List keys)
methods return objects managed by a BackingMap.
In a distributed ObjectGrid deployment, many different threads from different processes may try to update an object at about the same time. Updating an object involves three steps: getting the object out of the BackingMap, changing the object, and then committing the change to the BackingMap. When two or more different threads perform this step at about the same time, we could end up overwriting...