Interface SharedResource

    • Method Detail

      • refer

        default ResourceReference refer​(Object context)

        Creates a reference to this resource. You call this method to prevent an object from being destroyed until you have finished using it. You can attach a context that will live as long as the reference.

        Parameters:
        context - A context to be associated with the reference. It should give some clue as to who referenced it.

        You MUST keep the returned ResourceReference object and release the reference by calling ResourceReference.close() on it. A reference created by this method can NOT be released by calling release().

        See Also:
        ResourceReference.close()
      • release

        void release()

        Releases the "main" reference to this resource (the implicit reference due to creation of the object).

        References obtained by calling refer() must be released by calling ResourceReference.close() on the ResourceReference returned from refer(), NOT by calling this method. You call this method once you are done using an object that you have previously caused instantiation of.

        See Also:
        ResourceReference