Question d’entretien chez Spartez

Concurrency problems with HashMap

Réponse à la question d'entretien

Utilisateur anonyme

4 janv. 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.