using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace lablab
{
class Program
{
public static Thread thrd_red, thrd_yellow, thrd_green;
public static bool r1 = false;
public static bool r2 = false;
public static bool r3 = false;
public static void red()
{
Thread.Sleep(100);
while (true)
{
Console.WriteLine("red");
Thread.Sleep(2500);
thrd_yellow.Resume();
thrd_red.Suspend();
}
}
public static void yellow()
{
while (true)
{
Console.WriteLine("yellow");
Thread.Sleep(1500);
thrd_green.Resume();
thrd_yellow.Suspend();
}
}
public static void green()
{
while (true)
{
Console.WriteLine("green");
Thread.Sleep(500);
thrd_red.Resume();
thrd_green.Suspend();
}
}
static void Main(string[] args)
{
thrd_red = new Thread(red);
thrd_yellow = new Thread(yellow);
thrd_green = new Thread(green);
thrd_red.Start();
thrd_yellow.Start();
thrd_yellow.Suspend();
thrd_green.Start();
thrd_green.Suspend();
thrd_red.Join();
thrd_yellow.Join();
thrd_green.Join();
}
}
}