When the number of entries in the hash table exceeds the product of the load factor and the current capacity, the hash table is rehashed (that is, internal data structures are rebuilt) so that the hash table has approximately twice the number of buckets.
在 HashMap (Java Platform SE 8) 文档中有提到
简单说 rehash 就是因为 HashMap 的空间不够用了,所以需要分配一个大一点的空间,然后保存在里面的内容需要重新计算 hash。
HashMap 不是线程安全的,所以在 rehash 的过程中又有 put 操作……完全不可预料会发生什么,有可能是很坏的事情,线程安全是个大问题。