Interface ReferenceManager


  • 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.

    • Method Detail

      • register

        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.
        Throws:
        NullPointerException - If either object or cleanupAction are null.