Run N functions in parallel, and wait for all of them to be finished before starting another batch