how to overcome ConcurrentModificationException error
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/10134651/concurrent-modification-error-when-adding-elements-to-linkedlist">Concurrent modification error when adding elements to LinkedList</a>  </p>
</blockquote>



<p>i've a arraylist of linkedlist </p>

<pre><code>List&lt;LinkedList&lt;File1&gt;&gt; backup = new ArrayList&lt;LinkedList&lt;File1&gt;&gt;();
</code></pre>

<p>during runtime on clicking a button i want to remove few elements from a list and the add them in other list. 
i also tried declaring the linked list as </p>

<pre><code>List&lt;LinkedList&lt;File1&gt;&gt; lists = Collections.synchronizedList(new ArrayList&lt;LinkedList&lt;File1&gt;&gt;());
</code></pre>

<p>bt still the error remains the same . im not able to figure out the error , im also new to java so plz do help .
My code is as follows.</p>

<pre><code> private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // When delete button is clicked
        int parent_node = 0, d =0 ;
        File1 srt[] ;
        File1 deleted[] = new File1[no_node];
        Random randomGenerator = new Random();
        int rand_no = 0;
        while(rand_no == 0)
        {
            rand_no = randomGenerator.nextInt(no_node);
        }
        System.out.println("random no : " + rand_no);
         for(i=0;i&lt;backup.size();i++)
         {             
             ListIterator itr = it_bk.get(i);
             while(itr.hasNext())
             {
                 File1 file = (File1) itr.next();                 
                 if(rand_no == file.nod)
                 {                     
                     parent_node = i;
                     itr.remove();                     
                 }
             }
             //iterating back
             while(itr.hasPrevious())
              {
                  File1 file = (File1) itr.previous();
              }             
         }

         System.out.println("Parent node:" + parent_node);
         //add the nodes to parent
         ListIterator itr1 = it_bk.get(rand_no);

         System.out.println("randam node");

         while(itr1.hasNext())
         {
             File1 file = (File1) itr1.next();
             deleted[d] = new File1();
             deleted[d] = file ;
             d++;
             //tmp_bk.add(file); 
             System.out.println("node :" + file.nod + "\tdist :" + file.dist);
         }

         LinkedList&lt;File1&gt; tmp_bk = backup.get(parent_node);
         for(j=0;j&lt;d;j++)
         {
             tmp_bk.add(deleted[j]);
             System.out.println(deleted[j].nod + "\t" + deleted[j].dist);
         }
         //it_bk.add(tmp_bk.listIterator());
         ListIterator itr_p = it_bk.get(parent_node);
         System.out.println("parent node");
          while(itr_p.hasNext())
         {
             File1 file = (File1) itr_p.next();
             System.out.println("node :" + file.nod + "\tdist :" + file.dist);
         }

      }                
</code></pre>
