public class ReferenceQueue<T> extends Object
ReferenceQueue is the container on which reference objects are
enqueued when the garbage collector detects the reachability type specified
for the referent.| Modifier and Type | Field and Description |
|---|---|
static Reference<?> |
unenqueued |
| Constructor and Description |
|---|
ReferenceQueue()
Constructs a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
Reference<? extends T> |
poll()
Returns the next available reference from the queue, removing it in the
process.
|
Reference<? extends T> |
remove()
Returns the next available reference from the queue, removing it in the
process.
|
Reference<? extends T> |
remove(long timeoutMillis)
Returns the next available reference from the queue, removing it in the
process.
|
public static Reference<?> unenqueued
public Reference<? extends T> poll()
null if no reference is
immediately availablepublic Reference<? extends T> remove() throws InterruptedException
InterruptedException - if the blocking call was interruptedpublic Reference<? extends T> remove(long timeoutMillis) throws InterruptedException
timeoutMillis - maximum time to spend waiting for a reference object
to become available. A value of 0 results in the method
waiting indefinitely.null if no reference
becomes available within the timeout periodIllegalArgumentException - if timeoutMillis < 0.InterruptedException - if the blocking call was interrupted