static void Philosopher(Philosoph philosoph) { while (true) { philosoph.Think(); philosoph.TakeForks(); philosoph.Eat(); philosoph.PutForks(); } }
private static List <Philosoph> ComputePhilosophersList() { Philosoph p1 = new Philosoph(1); Philosoph p2 = new Philosoph(2); Philosoph p3 = new Philosoph(3); Philosoph p4 = new Philosoph(4); Philosoph p5 = new Philosoph(5); Philosoph p6 = new Philosoph(6); p1.SetNeighbors(p2, p4, p3); p2.SetNeighbors(null, p1, null); p3.SetNeighbors(p6, p5, p1); p4.SetNeighbors(p1, null, null); p5.SetNeighbors(p3, null, null); p6.SetNeighbors(null, p3, null); return(new[] { p1, p2, p3, p4, p5, p6 }.ToList()); }
public void SetNeighbors(Philosoph left, Philosoph right, Philosoph top) { Left = left; Right = right; Top = top; }