Advanced Distributed Systems module at HSLU
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
707 B

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace Sync_Ueb02_Latch
{
class RaceHorse
{
private ISynch startSignal;
private int nr;
public RaceHorse(int nr, ISynch startSignal)
{
this.nr = nr;
this.startSignal = startSignal;
}
public void Run()
{
Console.WriteLine("Rennpferd " + nr + " geht in die Startbox.");
startSignal.Acquire();
Console.WriteLine("Rennpferd " + nr + " läuft los.");
Thread.Sleep(new Random().Next(3000));
Console.WriteLine("Rennpferd " + nr + " ist im Ziel.");
}
}
}