java.lang.ref
Class ReferenceQueue
java.lang.Object
|
+--java.lang.ref.ReferenceQueue
public class
ReferenceQueueextends
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.
Author:See Also:
ReferenceQueue
public ReferenceQueue()
Creates a new empty reference queue.
poll
public synchronized Reference poll()
Checks if there is a reference on the queue, returning it
immediately. The reference will be dequeued.
Returns:
- a reference on the queue, if there is one,
null
otherwise.
remove
public Reference remove()
Removes a reference from the queue, blocking until a reference is
enqueued.
Returns:
- the reference removed from the queue.
Throws:
remove
public synchronized Reference remove(long timeout)
Removes a reference from the queue, blocking for timeout
until a reference is enqueued.
Parameters:
Returns:
- the reference removed from the queue, or
null
if timeout period expired.
Throws: