There may be multiple threads trying to call resize() and allocate their own new hash table (newkvs) before CAS it to the CHM._newkvs field, and only one will eventually succeed. Others allocation of the new (double sized) hash table will simply be a wasted effort.
The Java NBHM implementation limits the number of the threads that may try to allocate to 2. We should also port this.
There may be multiple threads trying to call
resize()
and allocate their own new hash table (newkvs
) before CAS it to theCHM._newkvs
field, and only one will eventually succeed. Others allocation of the new (double sized) hash table will simply be a wasted effort.The Java NBHM implementation limits the number of the threads that may try to allocate to 2. We should also port this.