find . -print0 | xargs -0 -n 1 -P 5 command
或
find . -print0 | parallel -0 command | use_output_if_needed
或
for i in *.log ; do
echo "$i"
[...do other needed stuff...]
sem -j10 gzip $i ";" echo done
done
sem --wait
等
答案 0 :(得分:3)
已经使用了几个月并且喜欢它!
如果您有任何疑问,请与我联系!
示例代码
require 'thread/pool'
pool = Thread.pool(5)
all_files.each do |f|
pool.process {
# Do Stuff
}
end
pool.shutdown