title: ConcurrentHashMap and Hash table difference
body: <p>I am new to Java and stackoverflow and am seeking answer from experienced folks, who have worked on Collections Framework. </p>
  
  <p>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. </p>
  
  <p>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? </p>
  
  <p>Any images/explanations/code on this would be really awesome. Thanks in advance.</p>