private static void SetupDinnerTable() { for (int i = 0; i < _mutexs.Length; i++) { _mutexs [i] = new Mutex(); } for (int i = 0; i < _philosophers.Length; i++) { if (i != 0) { _philosophers [i] = new Philosopher("Philosopher " + (i + 1), _mutexs [i], _mutexs [i - 1]); } else { _philosophers [i] = new Philosopher("Philosopher " + (i + 1), _mutexs [i], _mutexs [_mutexs.Length - 1]); } } }
public Philosopher(String threadName, Mutex leftChopstick, Mutex rightChopStick) : base(threadName) { _eatCount = 0; _leftChopStick = leftChopstick; _rightChopStick = rightChopStick; }