I am new to Java and stackoverflow and am seeking answer from experienced folks, who have worked on Collections Framework.
I read that hashTable is thread safe and so is concurrentHashMap, but a concurrentHashMap is faster than a hashTable, since it gives lock on segments of the map to the accessing threads.
How does this work internally? How is the size of segment decided? Example: if there are 40 entries in concurrentHashMap, and 3 threads trying to retrieve/modify data, how will the segments be decided?
Any images/explanations/code on this would be really awesome. Thanks in advance.