title: How to iterate over an array list in a thread safe manner (Java)
body: <p>I have an array list that I am using in my multi-threaded application, and I want a way to somehow be able to iterate through the array while not causing any exceptions to be thrown when I add a element to the list as I am iterating. Is there a way to stop the array list from being modified while I iterate through it?</p>
  
  <p>Edit:
  I now realize that my question was very poorly submitted, and the down votes are deserved. This is an attempt to fix my question.</p>
  
  <p>What I want to do is have some way to 'block' the list before I iterate through it so that I don't get a concurrent modification exception. The issue is that the iterating will take quite a bit of processor time to complete, because the list will be very large, and the action I wish to carry out on each element will take a fair amount of time. This is an issue if I use synchronized methods, because the add method will block for a large amount of time and decrease application performance. So what I am trying to do is create a class that imitates an array list, except that when it is 'blocked', and a method tries to modify it, it will store that request, and when the list is 'unblocked' it will perform all the requests in a separate thread. The issue is that when I try to implement this strategy, I have to store the requests in some sort of list, and run into the same problems I do before, with having to block the ability to add to the request list while the request thread is iterating over the requests. I'm at a loss for how to implement this solution, or even if it is the correct one. if anyone could help me that would be much appreciated.</p>