代码级别实现
:::code
{
#to do code
} &
多进程控制实现
:::code
task_id="`date '+%Y%m%d%H%M%S'`".${RANDOM}
THREAD_COUNT=3
rm ".{task_id}*running_flag"
for task in `cat ${task_file}`;do
{
_runing_flag=
touch ".{task_id}.${RANDOM}.`date '+%Y%m%d%H%M%S'`.running_flag"
# to do code
rm
}&
while [ `ls .${task_id}*running_flag` -ge ${THREAD_COUNT} ];do
sleep 10
done
done
上述代码解释