How to acquire a lock by a key
What is the best way to prevent concurrent update of one record in a key-value set without locking the entire set? Semantically, I'm looking for some kind of locking by a key (ideally, Java implementation, but not necessarily): interface LockByKey { void lock(String key); // acquire an exclusive lock for a key void unlock(String key); // release lock for a key } This lock is intended to synchronize an access to a remote store, so some synchronized Java collection is not an option. Louis Wasserman Guava has something like this being released in 13.0; you can get it out of HEAD if you like.