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

com.firefly.utils.collection.WeakReferenceConcurrentHashMap 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.WeakReference;

public class WeakReferenceConcurrentHashMap extends AbstractConcurrentAutomaticClearMap {

	private class ValueWeakReference extends WeakReference {

		K key;

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

	}

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

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy