Iterator and iteratorList with synchronization in java
<p>i  have an arraylist and i want to add and remove many items at he same(almost) time. So i decide to create 2 methods. In the first method i implement the method which contains the remove part i use something like:</p>

<pre><code>   //my list
   ArrayList&lt;Human&gt; list= new ArrayList&lt;Human&gt;(100);

   //Human is the object of the class Human
   List&lt;Human&gt; syncList = Collections.synchronizedList(new ArrayList&lt;Human&gt;());
   synchronized (syncList){

    for (Iterator&lt;Human&gt; iter = list.iterator(); iter.hasNext();) {
       Human = iter.next();
              -
              -
          //using the removes method of the iterator
          it.removes(something);
</code></pre>

<p>And in the second method (which i need to add many items) something like this:</p>

<pre><code>            for(  ListIterator&lt;Human&gt; it = list.listIterator();it.hasNext();){  
            List&lt;Human&gt; syncList = Collections.synchronizedList(newArrayList&lt;Human&gt;());
        synchronized (syncList){
                   -
                   - 
          //using the add method of the iterator list
          it.add(something)
</code></pre>

<p>Now i realize that when those two void methods finished and the list called by another function don't have the appropriate behaviour. I mean that some of the elements didn't add or removed from the list. How can i fix this?any ideas?</p>
