public class ReferenceManager
extends Object
Coordinates cleanup of managed references using idling, callback-driven, or threaded processing.
| Constructor and description |
|---|
ReferenceManager(ReferenceQueue queue)Creates a manager for the supplied queue. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
afterReferenceCreation(Reference r)Hook invoked after a new managed reference has been created. |
|
public static ReferenceManager |
createCallBackedManager(ReferenceQueue queue)Creates a manager that removes stale entries when new references are created. |
|
public static ReferenceManager |
createIdlingManager(ReferenceQueue queue)Creates a manager that only processes queued references when asked explicitly. |
|
public static ReferenceManager |
createThreadedManager(ReferenceQueue queue)Creates a manager backed by a daemon thread that drains the supplied queue. |
|
public static ReferenceManager |
createThresholdedIdlingManager(ReferenceQueue queue, ReferenceManager callback, int threshold)Creates a manager that starts in idling mode and switches to the callback manager after a threshold. |
|
public static ReferenceBundle |
getDefaultSoftBundle()
|
|
public static ReferenceBundle |
getDefaultWeakBundle()
|
|
protected ReferenceQueue |
getReferenceQueue()Returns the queue monitored by this manager. |
|
public void |
removeStallEntries()Removes any currently queued stale references. |
|
public void |
stopThread()Stops any background processing owned by this manager. |
|
public String |
toString(){@inheritDoc} |
Creates a manager for the supplied queue.
queue - the queue containing collected references, or null when not queue-backedHook invoked after a new managed reference has been created.
r - the created referenceCreates a manager that removes stale entries when new references are created.
queue - the queue to inspectCreates a manager that only processes queued references when asked explicitly.
queue - the queue to inspectCreates a manager backed by a daemon thread that drains the supplied queue.
queue - the queue to drainCreates a manager that starts in idling mode and switches to the callback manager after a threshold.
queue - the queue to inspectcallback - the manager to delegate to after the threshold is crossedthreshold - the number of created references before switching managersReturns the queue monitored by this manager.
nullRemoves any currently queued stale references.
Stops any background processing owned by this manager.
{@inheritDoc}
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.