Saturday 26 July 2014

java.lang.ref package

java.lang.ref package provides classes that provide limited interaction with garbage collector. The main feature of reference classes is, they can refer to an object that can still be reclaimed by the Garbage collector.

Class Hierarchy in java.lang.ref package

As shown in the figure, Reference is an abstract base class for reference objects. A Reference represents an indirect reference to an object, called the referent. Three types of reference(PhantomReference, WeakReference, SoftReference) objects are provided by this package, each type corresponds to a different level of garbage collection. Every reference object provides methods for getting and clearing the reference.

An object in memory is referenced by multple references like Strong(Hard), PhantomReference, WeakReference, SoftReference.



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment