main
Jan Bachmann 2024-10-29 10:38:57 +01:00
parent e3154b714d
commit a0f83a8672
1 changed files with 6 additions and 2 deletions

View File

@ -52,8 +52,12 @@ public class Philosopher extends Thread implements IPhilosopher {
log("left nor right eating"); log("left nor right eating");
this.eating = true; this.eating = true;
log("eating"); log("eating");
} finally {
table.unlock();
}
Thread.sleep(this.random.nextInt(MAX_EATING_DURATION_MS)); Thread.sleep(this.random.nextInt(MAX_EATING_DURATION_MS));
this.table.lock();
try {
this.eating = false; this.eating = false;
this.left.condition.signal(); this.left.condition.signal();
this.right.condition.signal(); this.right.condition.signal();