在每一要素需要处理时,我都有一个垃圾箱:
threads = []
elemets.each do |element|
threads.push(Thread.new{process(element)}}
end
threads.each { |aThread| aThread.join }
由于资源限制,如果在某一时间处理4个要素,文稿的工作方式是最佳的。
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 ?