title: Problems with two threads accessing a frequently updated Arraylist
body: <p>I have ArrayLists that store many objects, and objects are frequently added and removed from the ArrayLists. One thread operates on the data structures and updates the ArrayList's objects every 20ms or so. Another thread traverses the ArrayLists and uses their elements to paint the objects (also every 20-30ms). </p>
  
  <p>If the ArrayLists are traversed using a for loop, IndexOutOfBoundsExceptions abound. If the ArrayLists are traversed using iterators, ConcurrentModificationExceptions abound. Synchronizing the ArrayLists like so:</p>
  
  <p><pre><code>
  List list = Collections.synchronizedList(new ArrayList());
  synchronized(list) {
  //use iterator for traversals
  }
  </pre></code></p>
  
  <p>Throws no exceptions but has a substantial performance drain. Is there a way to traverse these ArrayLists without exceptions being throw, and without a performance drain?</p>
  
  <p>THANKS! </p>