top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How race condition works in Java hashmap?

+2 votes

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
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.