java multithread loop with collecting results
<p>sorry for limited code, as i have quite no idea how to do it, and parts of the code are not a code, just an explanation what i need. The base is:</p>

<pre><code>arrayList&lt;double&gt; resultTopTen = new arrayList&lt;double();
arrayList&lt;double&gt; conditions = new arrayList&lt;double(); // this arrayList can be of a very large size milion+, gets filled by different code

double result = 0;

for (int i = 0, i &lt; conditions.size(), i++){   //multithread this

loopResult = conditions.get(i) + 5; 

   if (result.size() &lt; 10){
      resultTopTen.add(loopResult);
   }
   else{
      //this part i don't know, if this loopResult belongs to the TOP 10 loopResults so far, just by size, replace the smallest one with current, so that i will get updated resultTopTen in this point of loop. 

   }
} 
</code></pre>

<ul>
<li>loopResult = conditions.get(i) + 5; part is just an example, calculation is different, in fact it is not even double, so it is not possible simply to sort conditions and go from there.</li>
<li>for (int i = 0, i &lt; conditions.size(), i++) part means i have to iterate through input condition list, and execute the calculation and get result for every condition in conditionlist, Don't have to be in order at all.</li>
<li>The multithreading part is the thing i have really no idea how to do, but as the conditions arrayList is really large, i would like to calculate it somehow in parallel, as if i do it just as it is in the code in a simple loop in 1 thread, i wont get my  computing resources utilized fully. The trick here is how to split the conditions, and then collect result. For simplicity if i would like to do it in 2 threads, i would split conditions in half, make 1 thread do the same loop for 1st half and second for second, i would get 2 resultTopTen, which i can put together afterwards, But much better would be to split the thing in to as many threads as system resources provide(for example until cpu ut &lt;90%, ram &lt;90%). Is that possible?</li>
</ul>