ConcurrentProgrammingCourse.../src/exercises/ex_j/Spoon.java

22 lines
372 B
Java
Raw Normal View History

2024-12-10 14:17:19 +00:00
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());
}
}