Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.lang.ref
Class ReferenceQueue  view ReferenceQueue download ReferenceQueue.java

java.lang.Object
  extended byjava.lang.ref.ReferenceQueue

public class ReferenceQueue
extends java.lang.Object

This is the queue, where references can enqueue themselve on. Each reference may be registered to a queue at initialization time and will be appended to the queue, when the enqueue method is called. The enqueue method may be automatically called by the garbage collector if it detects, that the object is only reachable through the Reference objects.


Field Summary
private  Reference first
          This is a linked list of references.
 
Constructor Summary
ReferenceQueue()
          Creates a new empty reference queue.
 
Method Summary
private  Reference dequeue()
          Remove a reference from the queue, if there is one.
(package private)  void enqueue(Reference ref)
          This is called by reference to enqueue itself on this queue.
 Reference poll()
          Checks if there is a reference on the queue, returning it immediately.
 Reference remove()
          Removes a reference from the queue, blocking until a reference is enqueued.
 Reference remove(long timeout)
          Removes a reference from the queue, blocking for timeout until a reference is enqueued.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

first

private Reference first
This is a linked list of references. If this is null, the list is empty. Otherwise this points to the first reference on the queue. The first reference will point to the next reference via the nextOnQueue field. The last reference will point to itself (not to null, since nextOnQueue is used to determine if a reference is enqueued).

Constructor Detail

ReferenceQueue

public ReferenceQueue()
Creates a new empty reference queue.

Method Detail

poll

public Reference poll()
Checks if there is a reference on the queue, returning it immediately. The reference will be dequeued.


enqueue

void enqueue(Reference ref)
This is called by reference to enqueue itself on this queue.


dequeue

private Reference dequeue()
Remove a reference from the queue, if there is one.


remove

public Reference remove(long timeout)
                 throws java.lang.InterruptedException
Removes a reference from the queue, blocking for timeout until a reference is enqueued.


remove

public Reference remove()
                 throws java.lang.InterruptedException
Removes a reference from the queue, blocking until a reference is enqueued.