Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.lang.ref

Class SoftReference

java.lang.Object
|
+--java.lang.ref.Reference
   |
   +--java.lang.ref.SoftReference


public class SoftReference

extends Reference

A soft reference will be cleared, if the object is only softly reachable and the garbage collection needs more memory. The garbage collection will use an intelligent strategy to determine which soft references it should clear. This makes a soft reference ideal for caches.

Author:

Constructor Summary

SoftReference(java.lang.Object referent)

Create a new soft reference, that is not registered to any queue.
SoftReference(java.lang.Object referent, java.lang.ref.ReferenceQueue q)

Create a new soft reference.

Method Summary

java.lang.Objectget()

Returns the object, this reference refers to.

Constructor Details

SoftReference

public SoftReference(java.lang.Object referent)

Create a new soft reference, that is not registered to any queue.

Parameters:


SoftReference

public SoftReference(java.lang.Object referent, java.lang.ref.ReferenceQueue q)

Create a new soft reference.

Parameters:

Throws:


Method Details

get

public Object get()

Returns the object, this reference refers to.

Returns: