title: ruby working on array elements in groups of four
body: <p>I have a ruby script  array when each element needs processing :</p>
  
  <pre><code>threads = []
  elemets.each do  |element|
      threads.push(Thread.new{process(element)}}
  end
  threads.each { |aThread|  aThread.join }
  </code></pre>
  
  <p>how ever due to resource limitations, the script works in an optimal way if no more the four elements are processed at a time. </p>
  
  <p>no I know I can dump the each loop and use a variable to count 4 elements and then wait 
  but is there a cooler ruby way to do it ?</p>