Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: java.util.ConcurrentModificationException Issue

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java.util.ConcurrentModificationException Issue

    While running the following code snippet at some scenario, I got the java.util.ConcurrentModificationException exception.
    Please advice: How to avoid it? what can be the worse scenario which ConcurrentModificationException can create? will it occupy the CPU Usage %? Any pointer would be great!!!
    public Map someMethod()
    {
    Map actionDosMap =new HashMap();
    List associatedActionsDos =new ArrayList();
    List associatedActionsPerformanceDos =new ArrayList();
     
    Iterator iterActions =associatedActions.iterator();
    while (iterActions.hasNext())
    {
    Iterator reposIt = reposSet.iterator();
                            while (reposIt.hasNext()) {
                                  RepoRow row = (RepoRow) reposIt.next();
                                  Properties props = row.getProperties();
     
                                  DoData performanceReportsDo = new DoData();
     
                                  if ("PerformanceReports".equals(props.getStringValue(do_type))) {
                                        performanceReportsDo.setDoType(doType);
                                        performanceReportsDo.setDoId(doID);                                  
                                        associatedActionsPerformanceDos.add(performanceReportsDo);
                                              }                     
                                        else
                                        {
                                  DoData doc = new DoData();
                                  doc.setDoType(doType);
                                  doc.setDoId(doID);                                                    
                                  associatedActionsDos.add(doc);
                                        }
     
              }
     
    }
    actionDosMap.put("performanceReportsDo",associatedActionsPerformanceDos);
    actionDosMap.put("actionsNonPerfoDo",associatedActionsDos);
    return actionDosMap;
    }
    Last edited by copeg; December 2nd, 2010 at 03:34 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,334
    Thanks
    181
    Thanked 830 Times in 773 Posts
    Blog Entries
    5

    Default Re: java.util.ConcurrentModificationException Issue

    Read the API for ConcurrentModificationException, in particular the mention of iterators, which may be the problem here. Your variables are not well defined in the above, so this is a guess but you are probably modifying a list while iterating through the iterator of said list.

Similar Threads

  1. How to Sort an Array using the java.util.Arrays class
    By JavaPF in forum Java SE API Tutorials
    Replies: 2
    Last Post: May 17th, 2014, 01:16 AM
  2. Replies: 1
    Last Post: December 22nd, 2011, 08:55 AM
  3. Replies: 3
    Last Post: April 26th, 2011, 02:51 AM
  4. java.util.* and visual studio 2005
    By natalie in forum Java Theory & Questions
    Replies: 0
    Last Post: February 26th, 2010, 09:34 AM
  5. Replies: 4
    Last Post: April 29th, 2009, 10:53 AM

Tags for this Thread