title: How to divide up the processing of a giant 3D cube?
body: <p>I'm not really sure how to ask this question, so if you can edit it so it's easier to understand, that would be great.</p>
  
  <p>I'm trying to process a large number of points in a 3D world in java (a <code>40*40*40</code> cube, so 64000 points in all). I want to divide up the following three dimensional <code>for</code> loop into maybe <code>10*10*10</code> segments, than to run it every few loops so other actions can be performed, so it isn't as slow. I tried using threads, but that constantly broke because my program was accessing two things at the same time.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>for (int x = 0; x &lt; 40; x++) {
      for (int y = 0; y &lt; 40; y++) {
          for (int z = 0; z &lt; 40; z++) {
              //Do stuff with x, y, and z
          }
      }
  }
  </code></pre>