Shell 多线程

'''

! /usr/bin/env bash

trap "exec 1000>&-;exec 1000<&-;exit 0" 2

mkfifo testfifo
exec 1000<>testfifo
rm -rf testfifo

for ((n=1;n<=10;n++))
do
echo >&1000
done

start=date "+%s"

for ((i=1;i<100;i++))
do
read -u1000
{
echo success$i; sleep 5
echo >&1000
}&
done
wait

end=date "+%s"
echo "time: expr $end - $start"

exec 1000>&-
exec 1000<&-

'''

posted on 2016-06-10 14:10  月下之风  阅读(631)  评论(0编辑  收藏  举报

导航