ConcurrentLinkedHashMapJava高性能集合类

联合创作 · 2023-09-28 21:05

ConcurrentLinkedHashMap是java.util.LinkedHashMap的一个高性能实现。主要用于软件缓存。


示例代码:


EvictionListener<K, V> listener = new EvictionListener<K, V>() {
@Override public void onEviction(K key, V value) {
System.out.println("Evicted key=" + key + ", value=" + value);
}
};
ConcurrentMap<K, V> cache = new ConcurrentLinkedHashMap.Builder<K, V>()
.maximumWeightedCapacity(1000)
.listener(listener)
.build();
浏览 25
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报