//import java.util.Vector;
import java.util.Stack;

public class TodoList
{
  //private Vector s = new Vector();  // or a Vector, or maybe an array...
  private Stack s = new Stack();  // or a Stack, or maybe an array...
  public int code;  // All submissions need this code or else
     // they get thrown away.

  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");
      }
    }

    //Object answer = s.firstElement();
    //s.removeElementAt(0);
    //return answer;               // pop the next object off the stack
    return(s.pop());               // pop the next object off the stack
  }

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

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