private void Eat() { firstFork.PickUp(this); secondFork.PickUp(this); State = PhilospherState.EATING; Thread.Sleep(50); Bites++; firstFork.PutDown(this); secondFork.PutDown(this); }
private void Eat() { tableSemaphore.Wait(); lock (firstFork) { lock (secondFork) { tableSemaphore.Release(); firstFork.PickUp(this); secondFork.PickUp(this); State = PhilospherState.EATING; // Thread.Sleep(50); Bites++; firstFork.PutDown(this); secondFork.PutDown(this); } } }