public Philosoph(String name, ChopStick right, ChopStick left) { Name = name; this.right = right; this.left = left; Thread t = new Thread(new ThreadStart(this.Live)); t.Start(); }
static void Main(string[] args) { int size = 5; Philosoph.sleepParameter = 20; ChopStick[] chopsticks = new ChopStick[size]; Philosoph[] philosophes = new Philosoph[size]; for (int i = 0; i < chopsticks.Length; i++) { chopsticks[i] = new ChopStick(); } for (int i = 0; i < chopsticks.Length; i++) { philosophes[i] = new Philosoph("P" + i, chopsticks[i], chopsticks[(i + 1) % size]); Thread.Sleep(500); } }