is there anything?
ConcurrentHashMap uses multiple buckets to store data. This avoids read locks and greatly improves performance over a HashTable .
Is it safe to replace the Hashtable instances with ConcurrentHashmap instances for performance gain? In most cases it should be safe and yield better performance. The effort on changing depends on whether you used the Map interface or Hashtable directly.
synchronizedMap() requires each thread to acquire a lock on the entire object for both read/write operations. By comparison, the ConcurrentHashMap allows threads to acquire locks on separate segments of the collection, and make modifications at the same time.
Creates a new, empty map with a default initial capacity (16), load factor (0.75) and concurrencyLevel (16).
There is a generic Dictionary class for implementing associative arrays (aka hashtables). Recently MS came out with the ConcurrentDictionary class: http://msdn.microsoft.com/en-us/library/dd287191.aspx which is probably what you want. It's .Net 4+ though. :(
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With