I get an error on the following line. I'm doing the process of adding to the jsonarray. Please help me.
jsonArr=new JSONArray();
if(req.getSession().getAttribute("userses")!=null){
String name=(req.getParameter("name")==null?"":to_EnglishName(req.getParameter("name").toUpperCase()));
if(!name.equals("")){
for(Book c:GlobalObjects.bookList){
if(c.getBookName().startsWith(name)){
jsonObjec=new JSONObject();
jsonObjec.put("label",c.getBookName());
jsonObjec.put("value", c.getId());
jsonArr.add(jsonObjec);//java.util.ConcurrentModificationException
}
}
}
}
jsonArr.write(res.getWriter());
Are you accessing jsonArr from another thread? i.e. Iterating over jsonArr when you are modifying it at the same time.
ConcurrentModificationException is thrown when you modify a collection at the same time while iterating it.