Ejemplo n.º 1
0
 /**
  * Dequeue the oldest object on the queue. Used only by the run() method.
  *
  * @return the oldest object on the queue.
  * @exception java.lang.InterruptedException if any thread has interrupted this thread.
  */
 private synchronized QueueElement dequeue() throws InterruptedException {
   while (tail == null) wait();
   QueueElement elt = tail;
   tail = elt.prev;
   if (tail == null) {
     head = null;
   } else {
     tail.next = null;
   }
   elt.prev = elt.next = null;
   return elt;
 }
Ejemplo n.º 2
0
  /**
   * Enqueue an event.
   *
   * @param event Either a <tt>NamingExceptionEvent</tt> or a subclass of <tt>NamingEvent</tt> or
   *     <tt>UnsolicitedNotificatoniEvent</tt>. If it is a subclass of <tt>NamingEvent</tt>, all
   *     listeners must implement the corresponding subinterface of <tt>NamingListener</tt>. For
   *     example, for a <tt>ObjectAddedEvent</tt>, all listeners <em>must</em> implement the
   *     <tt>ObjectAddedListener</tt> interface. <em>The current implementation does not check this
   *     before dispatching the event.</em> If the event is a <tt>NamingExceptionEvent</tt>, then
   *     all listeners are notified.
   * @param vector List of NamingListeners that will be notified of event.
   */
  synchronized void enqueue(EventObject event, Vector vector) {
    QueueElement newElt = new QueueElement(event, vector);

    if (head == null) {
      head = newElt;
      tail = newElt;
    } else {
      newElt.next = head;
      head.prev = newElt;
      head = newElt;
    }
    notify();
  }