ReferenceManager Interface

public interface ReferenceManager

This interface represents managing references to Objects and providing the ability to run a cleaning operation once the object is no longer able to be reference.

Expected usage of this is through INSTANCE.

Field Summary

Modifier and Type Field and Description
static final ReferenceManager INSTANCE

The global instance of ReferenceManager that should be used to maintain object references.

Method Summary

Modifier and Type Method and Description
abstract void register(Object object, Runnable cleanupAction)

Registers the object and the cleaning action to run once the object becomes phantom reachable.

Field Details

INSTANCE

public static final ReferenceManager INSTANCE

The global instance of ReferenceManager that should be used to maintain object references.

Method Details

register

public abstract void register(Object object, Runnable cleanupAction)

Registers the object and the cleaning action to run once the object becomes phantom reachable.

The cleanupAction cannot have a reference to the object, otherwise the object will never be able to become phantom reachable.

Exceptions thrown by cleanupAction are ignored.

Parameters:

object - The object to monitor.
cleanupAction - The cleanup action to perform when the object becomes phantom reachable.

Applies to