using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
static int numeration = 0;
static object locker = new object();
class Plant
{
int hase, paus , dira , nom;
public Plant(int ps , int hs,int dr){
hase = hs;
paus = ps;
dira = dr;
lock (locker)
{
nom = numeration++;
}
}
public void rost()
{
while (true)
{
lock (locker)
{
if (paus > dira)
{
dira++;
}
else
{
hase++;
if (hase == 1)
{
Console.Write("1");
dira = 0;
}
if (hase == 2)
{
Console.Write("2");
dira = 0;
}
if (hase == 3)
{
Console.Write("3");
dira = 0;
}
if (hase == 4)
{
Console.Write("4");
dira = 0;
}
if (hase == 5)
{
Console.Write("5");
dira = 0;
}
if (hase == 6)
{
Console.Write("6");
dira = 0;
}
if (hase == 7)
{
Console.Write("7");
dira = 0;
}
if (hase == 8)
{
Console.Write("8");
dira = 0;
}
if (hase > 8)
{
hase = 0;
dira = 0;
}
}
}
Thread.Sleep(3);
}
}
}
static void Main(string[] args)
{
for(int i=0; i<10; i++){
int hase = 0, dira = 400, paus = 1000;
Plant h = new Plant(paus, hase, dira);
Thread t = new Thread(h.rost);
t.Start();
}
}
}
}