final
parent
26ec95c75b
commit
29c257adea
|
@ -18,9 +18,8 @@ public interface IPhilosopher {
|
|||
|
||||
void stopPhilosopher();
|
||||
|
||||
void signal();
|
||||
|
||||
// boolean isEating();
|
||||
|
||||
|
||||
|
||||
default void log(int seat, String message) {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class Philosopher extends Thread implements IPhilosopher {
|
|||
try {
|
||||
while (left.eating || right.eating) {
|
||||
log(seat, "wartet");
|
||||
canEat.await(); // wartet, bis signal() von einem anderen Philosophen aufgerufen wird
|
||||
canEat.await();
|
||||
}
|
||||
eating = true;
|
||||
log(seat, "isst jetzt");
|
||||
|
@ -125,10 +125,4 @@ public class Philosopher extends Thread implements IPhilosopher {
|
|||
table.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// Gibt zurück, ob dieser Philosoph aktuell isst – wichtig für die Nachbarn.
|
||||
// public boolean isEating() {
|
||||
// return eating;
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue