import java.util.*;

public class Utensil extends Observable {
    String name;
    private boolean inuse;
    public Object observerRef;

    public Utensil(String n, Object r) {
	name = n;
	inuse = false;
	observerRef = r; 
    }
    public synchronized boolean isAvailable() { return !inuse; }
    public synchronized void pick_up() { 
	inuse = true; 
	setChanged();
	notifyObservers(observerRef);
    }
    public synchronized void put_down() { 
	inuse = false; 
	// when chopstick is dropped, do a notify
	notify();
	setChanged();
	notifyObservers(observerRef);
    }
}
