A simple ruby function to execute tasks in parallel through a number of threads.