Пример #1
0
 public Knight(int id, Rostrum rostrum, SleazyBar bar)
 {
     this.rostrum = rostrum;
     this.bar     = bar;
     this.random  = new Random(Guid.NewGuid().GetHashCode());
     this.id      = id;
 }
Пример #2
0
 private static void InitializeKnights(Rostrum rostrum, SleazyBar bar)
 {
     for (int i = 0; i < Configuration.NumberOfKnights; i++)
     {
         var knight = new Knight(i, rostrum, bar);
         new Thread(() => knight.Run()).Start();
     }
 }
Пример #3
0
        private static void InitializeWaiters(SleazyBar bar)
        {
            var wineWaiter      = new Waiter(ResourceType.Wine, bar);
            var cucumbersWaiter = new Waiter(ResourceType.Cucumbers, bar);

            new Thread(() => wineWaiter.Run()).Start();
            new Thread(() => cucumbersWaiter.Run()).Start();
        }
Пример #4
0
 public Waiter(ResourceType resource, SleazyBar bar)
 {
     this.resource = resource;
     this.bar      = bar;
     this.random   = new Random(Guid.NewGuid().GetHashCode());
 }