title: Some times java.util.ConcurrentModificationException thrown
body: <p>I executing below code but some times i got java.util.ConcurrentModificationException exception..But some times working fine.please let me know where i did wrong code.Below is my code please check my logic also if there is any better way then let me know.</p>
  
  <pre><code>    public  String saveSkills(HttpServletRequest request,@RequestParam String skills,@RequestParam String Email) throws IOException
      {
  
          Domain domain1 = (Domain)request.getSession().getAttribute("Domain");
          Long domanId =domain1.getDomainId();
          System.out.println(skills);
          String[] skillsParts = skills.split(",");
          UserProfile user = userProfileManager.getUserByEmail(domain1.getPrimary_Domain_Id(), Email);
          if(user.getSkillsList().size()&gt;0){
              Iterator it = user.getSkillsList().iterator();
              while (it.hasNext())
              {
                  Skills skillsitereator = (Skills) it.next();
                  int count=0;
  
                  for(int i =0;i&lt;skillsParts.length;i++){
  
                      if((skillsParts)[i].equals(skillsitereator.getSkillName())){
  
                          break;
  
                      }else{
  
                          count++;
                      }
                  }
                  if(count == skillsParts.length){
                      it.remove();
                      userProfileManager.update(user);
                  }
              }
          }else{
  
              for(int i =0;i&lt;skillsParts.length;i++){
  
                  Skills skillObj = new Skills();
                  skillObj.setSkillName(skillsParts[i]);
                  user.getSkillsList().add(skillObj);
  
              }
              userProfileManager.update(user);
          }
          skillsParts = skills.split(",");
          System.out.println(skillsParts);
          ArrayList&lt;Integer&gt; values =new ArrayList&lt;Integer&gt;();
          for(int i =0;i&lt;skillsParts.length;i++){
              Iterator it = user.getSkillsList().iterator();
              while (it.hasNext())
              {
                  Skills skillsitereator = (Skills) it.next();
                  if((skillsParts)[i].trim().equals(skillsitereator.getSkillName().trim())){
                      break;
                  }
                  else{
  
                      Skills skillObj = new Skills();
                      skillObj.setSkillName(skillsParts[i]);
                      user.getSkillsList().add(skillObj);
                      userProfileManager.update(user);
                  }
              }
          }
          Gson gson = new Gson();
          return gson.toJson(user);
      }
  </code></pre>