Java Reference abstract class, javareference Abstract
I. Overview
In the java. lang. ref package, declare: public abstract classReference <T>ExtendsObject
The abstract base class of the referenced object. This class defines operations that are commonly used to reference objects. Because the referenced object is implemented through close cooperation with the garbage collector, you cannot directly create a subclass for this class.
Ii. Detailed Methods
1,Public Tget () returns the indicator object of this referenced object. If the referenced object has been cleared by a program or garbage collector, this method returnsnull.
2. public voidClear() Clear the referenced object. Calling this method will not cause the object to be added to the queue. This method is called only by Java code. When the Garbage Collector clears references, you can directly perform operations without calling this method.
3. public booleanIsEnqueued() The program or garbage collector notifies you whether the referenced object has been added to the queue. If this reference object is not registered in the queue when it is created, this method will always returnfalse.
Return Value:Returned only when the referenced object has been added to the queuetrue
4、Public booleanEnqueue() Add this reference object to the queue that the reference object has registered with (if any ). This method is called only by Java code. When the Garbage Collector adds references to the queue, you can directly perform operations without calling this method.
Return Value:If the referenced object is successfully added to the queue
trueIf it has already been added to the queue or is not registered in the queue when it was created, the system returns
false.