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

com.firefly.utils.collection.SoftReferenceConcurrentHashMap Maven / Gradle / Ivy

There is a newer version: 4.0.3.2
Show newest version
package com.firefly.utils.collection;

import java.lang.ref.Reference;
import java.lang.ref.SoftReference;

public class SoftReferenceConcurrentHashMap extends AbstractConcurrentAutomaticClearMap {

	private class ValueSoftReference extends SoftReference {

		K key;

		public ValueSoftReference(K key, V value) {
			super(value, refQueue);
			this.key = key;
		}

	}

	@SuppressWarnings("unchecked")
	@Override
	protected void clearInvalidEntry(Reference ref) {
		map.remove(((ValueSoftReference) ref).key);
	}

	@Override
	protected Reference createRefence(K key, V value) {
		return new ValueSoftReference(key, value);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy