Änderungen 05.12.2023 um 14:44

This commit is contained in:
leonmcfly 2023-12-05 14:44:49 +01:00
parent 6f46678393
commit 582ed1a694
2 changed files with 23 additions and 5 deletions

View File

@ -10,16 +10,27 @@ public class Fork {
}
public int getId(){
return id;
}
public boolean take(){
synchronized (this){
if (inUse){
return false;
}
inUse = true;
try {
Thread.sleep(1000);
}catch (InterruptedException e){
System.out.println("Gabel mit ID: " + id + " hat nicht funktioniert");
}
return true
}
}
public void put(){
synchronized(this){
inUse = false;
}
}
}

View File

@ -0,0 +1,7 @@
package Prog3.src.DiningPhilosophers;
import static org.junit.jupiter.api.Assertions.*;
class ForkTest {
}