title: How can I divide into threads using ExecuterService?
body: <p>I have an array which has ~ 5 000 objects. For each object I'm planning to execute some logic. The logic is the same for each object. I want to do it as fast as i can, so i came to ExecutorService, which is in java.util.cuncurrent. I have decided to work with 100 objects in a thread, so i have divided my total number (~5k) into intervals</p>
  
  <pre><code>private List&lt;Integer&gt; divideIntoIntervals(Integer total)
  {
      List&lt;Integer&gt; intervals = new ArrayList&lt;Integer&gt;();
      intervals.add(0);
      int n = total / PART_SIZE;
  
      int leftover = total % PART_SIZE;
      if(n!=0)
      {
          intervals.add(PART_SIZE);
          for (int i=2; i&lt;=n; i++)
          {
              intervals.add(PART_SIZE*i);
          }
          intervals.add(PART_SIZE*n+leftover);
      }
  
      return intervals;
  }
  </code></pre>
  
  <p>so, the array would be like: 0, 100, 200, 300, ... , 5000, 5041.
  What cuncurrent list would you suggest?
  I'm planning to create logic, which seeks my cuncurrent array for another interval to work with.</p>