title: Best way to control concurrent access to Java collections
body: <p>Should I use old synchronized Vector collection, ArrayList with synchronized access or Collections.synchronizedList or some other solution for concurrent access?</p>
  
  <p>I don't see my question in Related Questions nor in my search (<a href="https://stackoverflow.com/questions/164088/make-your-collections-thread-safe" title="Make your collections thread-safe?">Make your collections thread-safe?</a> isn't the same).</p>
  
  <p>Recently, I had to make kind of unit tests on GUI parts of our application (basically using API to create frames, add objects, etc.).
  Because these operations are called much faster than by a user, it shown a number of issues with methods trying to access resources not yet created or already deleted.</p>
  
  <p>A particular issue, happening in the EDT, came from walking a linked list of views while altering it in another thread (getting a ConcurrentModificationException among other problems).
  Don't ask me why it was a linked list instead of a simple array list (even less as we have in general 0 or 1 view inside...), so I took the more common ArrayList in my question (as it has an older cousin).</p>
  
  <p>Anyway, not super familiar with concurrency issues, I looked up a bit of info, and wondered what to choose between the old (and probably obsolete) Vector (which has synchronized operations by design), ArrayList with a <code>synchronized (myList) { }</code> around critical sections (add/remove/walk operations) or using a list returned by Collections.synchronizedList (not even sure how to use the latter).</p>
  
  <p>I finally chose the second option, because another design mistake was to expose the object (getViewList() method...) instead of providing mechanisms to use it.</p>
  
  <p>But what are the pros and cons of the other approaches?</p>
  
  <hr>
  
  <p>[EDIT] Lot of good advices here, hard to select one. I will choose the more detailed and providing links/food for thoughts... :-) I like Darron's one too.</p>
  
  <p>To summarize:</p>
  
  <ul>
  <li>As I suspected, Vector (and its evil twin, Hashtable as well, probably) is largely obsolete, I have seen people telling its old design isn't as good as newer collections', beyond the slowness of synchronization forced even in single thread environment. If we keep it around, it is mostly because older libraries (and parts of Java API) still use it.</li>
  <li>Unlike what I thought, Collections.synchronizedXxxx aren't more modern than Vector (they appear to be contemporary to Collections, ie. Java 1.2!) and not better, actually. Good to know. In short, I should avoid them as well.</li>
  <li>Manual synchronization seems to be a good solution after all. There might be performance issues, but in my case it isn't critical: operations done on user actions, small collection, no frequent use.</li>
  <li>java.util.concurrent package is worth keeping in mind, particularly the CopyOnWrite methods.</li>
  </ul>
  
  <p>I hope I got it right... :-)</p>