软引用

 

1.Weak references are useful for mappings that 

should have their entries removed automatically 
once they are not referenced any more
弱引用 对映射数据有用,并且不再引用时被自动删掉
源码:

public class WeakReference<T> extends Reference<T> {

/**
* Constructs a new weak reference to the given referent. The newly created
* reference is not registered with any reference queue.
*
* @param r the referent to track
*/
public WeakReference(T r) {
super(r, null);
}

/**
* Constructs a new weak reference to the given referent. The newly created
* reference is registered with the given reference queue.
*
* @param r the referent to track
* @param q the queue to register to the reference object with. A null value
* results in a weak reference that is not associated with any
* queue.
*/
public WeakReference(T r, ReferenceQueue<? super T> q) {
super(r, q);
}
}

posted @ 2015-07-14 14:17  qianrushi5  阅读(118)  评论(0编辑  收藏  举报