public Knight(int id, Rostrum rostrum, SleazyBar bar) { this.rostrum = rostrum; this.bar = bar; this.random = new Random(Guid.NewGuid().GetHashCode()); this.id = id; }
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(); } }
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(); }
public Waiter(ResourceType resource, SleazyBar bar) { this.resource = resource; this.bar = bar; this.random = new Random(Guid.NewGuid().GetHashCode()); }