Hello All,
I am getting concurrent modification exception while I have only a single main thread running.I am not sure why I am getting this exception.I tried to put final keyword before the iterator in the abpve code snippet and also tried to synchronize access to the lists but nothing worked.Please help me out with this.
Iterator it3;
while(rs1_bookmark_train.next())
{
String description=rs1_bookmark_train.getString(4);
//Split the desc according to spaces....
description=description.trim();
//Need to add more delimiters
StringTokenizer st1=new StringTokenizer(description," ");
//Iterator it3;
//considering each token in the description in testing data..we need to calculate the score for that..
while(st1.hasMoreTokens())
{
String tok=st1.nextToken();
tok=tok.toLowerCase();
if(!hstop.containsKey(tok))
{
int current_contentid=rs1_bookmark_train.getInt(1);
//Obtains a list of tags corresponding to the content id
List tagList=contentid_tag_list.get(current_contentid);
//This will iterate over the the list of tags corresponding to the current content id
// it3=tagList.iterator();
//Checks if the title word pre-exists in the hash table or it is a new word
if(title_word_cooccurred_tags.containsKey(tok))
{
//Obtains the pre-existing list of co-occurring tags corresponding to the title word
List s=title_word_cooccurred_tags.get(tok);
it3=tagList.iterator();
String currentTag=" ";
while(it3.hasNext())
{
//Obtaining concurrent modification exception on this line!
currentTag=it3.next().toString();
s.add(currentTag);
}
System.gc();
it3=null;
}
else
{
title_word_cooccurred_tags.put(tok, tagList);
}
}
}
}