ReferenceQueue
ReferenceQueue is a class from the java.lang.ref package that facilitates the notification of garbage collector events for objects that are referenced by java.lang.ref objects such as SoftReference, WeakReference, and PhantomReference. An instance of ReferenceQueue can be associated with any of these reference objects. When the garbage collector determines that a referenced object is no longer strongly reachable, it will enqueue the corresponding reference object onto the ReferenceQueue. Applications can then poll or remove references from the queue to detect when the referent has become eligible for reclamation, allowing the program to perform cleanup actions, release native resources, or otherwise manage memory more efficiently.
The primary methods of ReferenceQueue are poll() and remove(). poll() returns the next reference in the queue
ReferenceQueue is particularly useful for implementing caches that rely on soft references, or for detecting when