All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.lang.ref.SoftReference Maven / Gradle / Ivy

package java.lang.ref;

public class SoftReference extends Reference {
	private long time;

	static private long getTime() {
		return System.currentTimeMillis();
	}

	public SoftReference(T referent) {
		super(referent);
		this.time = getTime();
	}

	public SoftReference(T referent, ReferenceQueue q) {
		super(referent, q);
		this.time = getTime();
	}

	public T get() {
		T o = super.get();
		long current = getTime();
		if (o != null && this.time != current) this.time = current;
		return o;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy