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 {
table.lock();
try {
while (left.essen | right.essen) {
if (left.essen) {
left.cond.await();
}
right.cond.await();
while (left.essen || right.essen) {
cond.await();
}
essen = true;
} finally {
@ -90,7 +87,8 @@ public class Philosopher extends Thread implements IPhilosopher {
table.lock();
try {
essen = false;
cond.signalAll();
left.cond.signal();
right.cond.signal();
} finally {
table.unlock();
}