ConcurrentProgrammingCourse.../src/exercises/ex_j/Spoon.java
2024-12-10 15:17:19 +01:00

22 lines
372 B
Java

package exercises.ex_j;
class Spoon {
private Diner owner;
public synchronized Diner getOwner() {
return owner;
}
public Spoon(Diner d) {
owner = d;
}
public synchronized void setOwner(Diner d) {
owner = d;
}
public synchronized void use() {
System.out.printf("%s has eaten!", owner.getName());
}
}