import java.util.Stack;

public class TodoList
{
  private Stack s = new Stack();  // or a Vector, or maybe an array...

  public synchronized Object get()
  {
    while(s.isEmpty()) {           // make sure an object is available
      // sleep until someone calls notifyAll()
      try { wait(); }
      catch (InterruptedException e) { 
        System.err.println("Interrupted Exception on TodoList");
      }
    }

    return s.pop();               // pop the next object off the stack
  }

  public synchronized void put(Object obj)
  {
    s.push(obj);                  // push the objet onto the stack
    notifyAll();                  // tap waiting threads on the shoulder
  }

  public synchronized void trashall() {
    s = new Stack();
  }
}
