java - ConcurrentModificationException when invoking putAll -


i have difficulties in understanding following error.

suppose have class in implement following method:

map<double,integer> get_friends(double user){  map<double,integer> friends = user_to_user.row(user); //friends.putall(user_to_user.column(user));  return friends;} 

then in main following:

a obj = new a(); map<double,integer> temp = obj.get_friends(6); 

well works fine. when uncomment follwing line in class a:

friends.putall(user_to_user.column(user)); 

and run again program, crashes , throws me concurrentmodificationexception. noted, creating table user_to_user follows:

private hashbasedtable<double,double,integer> user_to_user;// user_to_user = hashbasedtable.create(); 

what further surprising when interchange way filling friends, mean in way:

map<double,integer> friends = user_to_user.column(user); friends.putall(user_to_user.row(user)); 

then everyting work fine. idea ?

the issue hashbasedtable internally implemented map<double, map<double, integer>>, , implementation of user_to_user.column(user) iterating on rows @ same time you're modifying row associated user.

one workable alternative copy user_to_user.column(user) separate map before putting row.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -