diff --git a/pp.A1-CondPhilosophers/src/main/java/pp/Philosopher.java b/pp.A1-CondPhilosophers/src/main/java/pp/Philosopher.java index 247ec3b..3893d9c 100644 --- a/pp.A1-CondPhilosophers/src/main/java/pp/Philosopher.java +++ b/pp.A1-CondPhilosophers/src/main/java/pp/Philosopher.java @@ -52,8 +52,12 @@ public class Philosopher extends Thread implements IPhilosopher { log("left nor right eating"); this.eating = true; log("eating"); - Thread.sleep(this.random.nextInt(MAX_EATING_DURATION_MS)); - + } finally { + table.unlock(); + } + Thread.sleep(this.random.nextInt(MAX_EATING_DURATION_MS)); + this.table.lock(); + try { this.eating = false; this.left.condition.signal(); this.right.condition.signal();