Fix basierend auf aussage Sandro Leuchter

main
ChaosLL1337 2026-10-26 10:20:01 +01:00
parent f5ff3d11f1
commit 971573c3b1
1 changed files with 4 additions and 6 deletions

View File

@ -74,11 +74,8 @@ public class Philosopher extends Thread implements IPhilosopher {
private void startEating() throws InterruptedException { private void startEating() throws InterruptedException {
table.lock(); table.lock();
try { try {
while (left.essen | right.essen) { while (left.essen || right.essen) {
if (left.essen) { cond.await();
left.cond.await();
}
right.cond.await();
} }
essen = true; essen = true;
} finally { } finally {
@ -90,7 +87,8 @@ public class Philosopher extends Thread implements IPhilosopher {
table.lock(); table.lock();
try { try {
essen = false; essen = false;
cond.signalAll(); left.cond.signal();
right.cond.signal();
} finally { } finally {
table.unlock(); table.unlock();
} }