-
#!/bin/bash
-
function a_sub {
-
sleep 2
-
}
-
-
tmp_fifofile="/tmp/$$.fifo"
-
mkfifo $tmp_fifofile
-
exec 6<>$tmp_fifofile
-
rm $tmp_fifofile
-
-
thread=15
-
for ((i=0;i<$thread;i++));do
-
echo
-
done >&6
-
-
for ((i=0;i<50;i++));do
-
read -u6
-
{
-
a_sub && {
-
echo "a_sub is finished"
-
} || {
-
echo "sub error"
-
}
-
echo >&6
-
}&
-
done
-
wait
-
exec 6>&-
- exit 0
...
...
...
real 0m8.010s
user 0m0.014s
sys 0m0.054s