title: Perl or Bash threadpool script?
body: <p>I have a script - a linear list of commands - that takes a long time to run sequentially.  I would like to create a utility script (Perl, Bash or other available on Cygwin) that can read commands from any linear script and farm them out to a configurable number of parallel workers.</p>
  
  <p>So if <code>myscript</code> is</p>
  
  <pre><code>command1
  command2
  command3
  </code></pre>
  
  <p>I can run:</p>
  
  <pre><code>threadpool -n 2 myscript
  </code></pre>
  
  <p>Two threads would be created, one commencing with <code>command1</code> and the other <code>command2</code>.  Whichever thread finishes its first job first would then run <code>command3</code>.</p>
  
  <p>Before diving into Perl (it's been a long time) I thought I should ask the experts if something like this already exists.  I'm sure there should be something like this because it would be incredibly useful both for exploiting multi-CPU machines and for parallel network transfers (<code>wget</code> or <code>scp</code>).  I guess I don't know the right search terms.  Thanks!</p>