#!/bin/bash
mkfifo mylist
(资料图)
exec 2<>mylist
a1=0
a2=0
a3=0
a4=0
a5=0
for((i=0;i<=2;i++));
do
{
{
if [ $a2 -eq 0 ] && [ $a5 -eq 0 ]
then
sleep 1
echo "A start eatting"
echo "A has eaten"
a1=1
sleep 1
else
a1=0
sleep 1
fi
}&
{
if [ $a1 -eq 0 ] && [ $a3 -eq 0 ]
then
sleep 1
echo "B start eatting"
echo "B has eaten"
a2=1
sleep 1
else
a2=0
sleep 1
fi
}&
{
if [ $a2 -eq 0 ] && [ $a4 -eq 0 ]
then
sleep 1
echo "C start eatting"
echo "C has eaten"
a3=1
sleep 1
else
a3=0
sleep 1
fi
}&
{
if [ $a3 -eq 0 ] && [ $a5 -eq 0 ]
then
sleep 1
echo "D start eatting"
echo "D has eaten"
a4=1
sleep 1
else
a4=0
sleep 1
fi
}&
{
if [ $a4 -eq 0 ] && [ $a1 -eq 0 ]
then
sleep 1
echo "E start eatting"
echo "E has eaten"
a5=1
sleep 1
else
a5=0
sleep 1
fi
}&
wait
}
done
echo "ABCDE have all eaten"
exec 2<&-
exec 2>&-
rm -f mylist
关键词:
Copyright 2015-2022 南极供销网版权所有 备案号: 粤ICP备2022077823号-13 联系邮箱: 317 493 128@qq.com