Provides a number of mutexes which allow fine-grained concurrency. Rather than locking a cache or a store, the individual elements or constituent objects can be locked. This dramatically increases the possible concurrency.
The more stripes, the higher the concurrency. To be threadsafe, the instance of StripedMutex needs to be maintained for the entire life of the cache or store, so there is some added memory use.
Though a new class, this code has been refactored from
BlockingCache
, where it has been in use in highly concurrent production environments for years.
Based on the lock striping concept from Brian Goetz. See Java Concurrency in Practice 11.4.3
@author Greg Luck