Locks on objects need to be stored somewhere accessible to different threads. Much like how objects are stored in buckets in the BackingMap, locks are also stored in buckets. This brings us to the numberOfBuckets
and numberOfLockBuckets
settings on a BackingMap. These settings are implementation details of a BackingMap, but it's important to know these details in order to assign optimum settings for concurrency and performance. BackingMaps use a hash table data structure to store objects.
Let's review a basic implementation of the hash map data structure so we know what the number of buckets means. Hash maps store objects in buckets. A bucket is a place for a value object keyed with a key object. A good key object is an integer, and as luck would have it, the hashCode()
method on java.lang.Object
returns an integer value. Because every object in Java inherits from java.lang.Object
, we have the hashCode()
method available to any object we create. We should...