I. Overview
Class Structure:
Java.lang.Object java.lang.ref.reference<t> java.lang.ref.weakreference<t>
Statement:Public classweakreference<t>Extends reference<t>
Assume that the garbage collector determines that an object is a weakly reachable object at a point in time. At this point, it will automatically clear all weak references to this object, as well as all weak references to any other weakly reachable objects that can be reached from the object by strong reference chains and soft references. It will also declare all previous weakly reachable objects to be terminated. At the same time or later, it joins the queue with weak references to new purges that have been registered with the reference queue.
Second, the construction method
1. public weakreference(T referent) Creates a new weak reference that references the given object. The new reference is not registered with any queue.
Parameters: referent -The new weak reference will reference the object
2. Public weakreference(T referent, referencequeue<? supert> q) Creates a new weak reference that references the given object and registers the reference with the given queue.
Parameters: referent -The new weak reference will refer to the object q -the queue to which the reference is registered, or null if registration is not required;
Weak reference WeakReference in Java