next_in = 0; next_out = 0;   dispatchThread.interrupt (); dispatchThread = null;
  protected void pop() throws EmptyStackException  {    if (prev == null)      throw new EmptyStackException();    // Don't synchronize both this and prev at the same time, or deadlock could    // occur.    synchronized (prev)      {        prev.next = null;      }    synchronized (this)      {        int i = next_out;        while (i != next_in)          {            prev.postEvent(queue[i]);            next_out = i;            if (++i == queue.length)              i = 0;          }      }  }