Bukkit/Bukkit — pull request #878 by crast (2013-06-01 22:07:38+00:00)
Title: Reduce thread synchronization in MetadataStoreBase [BUKKIT-4294]

MetadataStoreBase [as is currently written](https://github.com/Bukkit/Bukkit/blob/410bd305b874474c7e9c6f005c5cab53cfad9b58/src/main/java/org/bukkit/metadata/MetadataStoreBase.java) has every method synchronized. This means that even for read-access (and the metadata is intentionally quite a read-heavy API) that a lock must be acquired every single time, across the entire store.

This can be avoided by using a ConcurrentHashMap, and even the locks on writing can be cleaned up substantially. This means all calls to `getMetadata` and `hasMetadata` **use no locking at all** and calls to `setMetadata`/`removeMetadata` lock on a much more fine-grained object (in other words, the only time two threads would have contention is if they're both setting the _exact_ same key. This allows taking advantage of atomic primitives while still being thread-safe.