标签:shell 多线程
1:
#!/bin/bash for i in $(seq 1 1000)do ( Generating random numbers here , sorting and outputting to file$i.txt ) & if (( $i % 10 == 0 )); then wait; fi # Limit to 10 concurrent subshells. done wait
2:
for ARG in $*; do
command $ARG &
NPROC=$(($NPROC+1))
if [ "$NPROC" -ge 4 ]; then
wait
NPROC=0
fi
done
本文出自 “行者” 博客,请务必保留此出处http://223228686.blog.51cto.com/2222284/1773511
标签:shell 多线程
原文地址:http://223228686.blog.51cto.com/2222284/1773511