top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How race condition works in Java hashmap?

+2 votes
1,705 views

Can someone explain in detail how race condition works in Java hashmap?

posted Sep 18, 2013 by Arvind Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Hashmap could run into race condition if it would be modified by two thread simultaneous and one thread tries to resize or rehash the map because of capacity crossing threshold value. since hashmap maintains a linked list of element in bucket and while copying from one hashmap to other or old to new order of linked list got reversed, which could result in infinite loop if two threads are doing resizing at same time.

answer Sep 18, 2013 by Arvind Singh
...