Class WeakReference

java.lang.Object
java.lang.ref.Reference
java.lang.ref.WeakReference

public class WeakReference extends Reference
This class provides support for weak references. Weak references are most often used to implement canonicalizing mappings. Suppose that the garbage collector determines at a certain point in time that an object is weakly reachable. At that time it will atomically clear all the weak references to that object and all weak references to any other weakly- reachable objects from which that object is reachable through a chain of strong and weak references. Since: JDK1.2, CLDC 1.1
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new weak reference that refers to the given object.
  • Method Summary

    Methods inherited from class Reference

    clear, get
    Modifier and Type
    Method
    Description
    void
    Clears this reference object.
    get()
    Returns this reference object's referent.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    boolean
    Indicates whether some other object is "equal to" this one.
    final Class
    Returns the runtime class of an object.
    int
    Returns a hash code value for the object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • Constructor Details

    • WeakReference

      public WeakReference(Object ref)
      Creates a new weak reference that refers to the given object.