Test-SJ
Shahnam Javidnia 2025-05-03 20:31:10 +02:00
parent 26ec95c75b
commit 29c257adea
2 changed files with 2 additions and 9 deletions

View File

@ -18,9 +18,8 @@ public interface IPhilosopher {
void stopPhilosopher(); void stopPhilosopher();
void signal();
// boolean isEating();
default void log(int seat, String message) { default void log(int seat, String message) {

View File

@ -91,7 +91,7 @@ public class Philosopher extends Thread implements IPhilosopher {
try { try {
while (left.eating || right.eating) { while (left.eating || right.eating) {
log(seat, "wartet"); log(seat, "wartet");
canEat.await(); // wartet, bis signal() von einem anderen Philosophen aufgerufen wird canEat.await();
} }
eating = true; eating = true;
log(seat, "isst jetzt"); log(seat, "isst jetzt");
@ -125,10 +125,4 @@ public class Philosopher extends Thread implements IPhilosopher {
table.unlock(); table.unlock();
} }
} }
// Gibt zurück, ob dieser Philosoph aktuell isst wichtig für die Nachbarn.
// public boolean isEating() {
// return eating;
// }
} }