import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap;
/**
* 跳表的使用
*/
public class ConcurrentSkipListMapDemo {
public static void main(String[] args){
ConcurrentSkipListMap<Integer, Integer> map = new ConcurrentSkipListMap<>();
for (int i = 0; i < 30; i++) {
map.put(i,i);
}
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey());
}
}
//0
//1
//2
//3
//4
//5
//6
//7
//8
//9
//10
//11
//12
//13
//14
//15
//16
//17
//18
//19
//20
//21
//22
//23
//24
//25
//26
//27
//28
//29
//输出是有序的
}
转载于:https://www.cnblogs.com/fly-book/p/11466503.html
本文通过示例代码详细介绍了跳表的基本概念及其在Java中的实现——ConcurrentSkipListMap。ConcurrentSkipListMap是一种高性能的并发映射容器,它提供了线程安全的插入、删除和查找操作,同时保持了良好的并发性能。本文展示了如何创建并使用ConcurrentSkipListMap,以及其内部数据结构如何保证操作的高效性和线程安全性。
1314

被折叠的 条评论
为什么被折叠?



