Pregunta de entrevista de Spartez

Concurrency problems with HashMap

Respuesta de la entrevista

Anónimo

4 ene 2019

What could happen when adding a value to the hash map: this can cause a rehash of the table, and if that occurs while another thread is iterating over a collision list (a hash table "bucket"), that thread could erroneously fail to find a key that exists in the map. HashMap is explicitly unsafe for concurrent use. Use ConcurrentHashMap instead.