title: How to use multiple threads in Java to iterate over a Collection where no two threads ever iterate over the same part of the Collection?
body: <p>I need to iterate over a large <code>ArrayList</code> (~50,000 entries) and I need to use multiple threads to do this fairly quickly.</p>
  
  <p>But I need each thread to start at a unique index so that no two threads ever iterate over the same part of the list. There will be a <code>batchSize</code> of <code>100</code> so each thread will loop from its <code>startIndex</code> to <code>startIndex + 100</code>.</p>
  
  <p>Is there any way to achieve this? Note that I am only performing read operations here, no writes. Each entry in the list is just a String which is actually an SQL query which I am then executing against a DB via JDBC.</p>