文章目录
1.世界
1. ConcurrentSkipListSet介绍
ConcurrentSkipListSet是线程安全的有序
的集合,适用于高并发的场景。ConcurrentSkipListSet和TreeSet,它们虽然都是有序的集合。但是,
- 它们的线程安全机制不同,TreeSet是非线程安全的,而ConcurrentSkipListSet是线程安全的
- ConcurrentSkipListSet是通过ConcurrentSkipListMap实现的,而TreeSet是通过TreeMap实现的。
2. ConcurrentSkipListSet原理和数据结构
ConcurrentSkipListSet的数据结构,如下图所示:
说明:
- ConcurrentSkipListSet继承于AbstractSet。因此,它本质上是一个集合。
- ConcurrentSkipListSet实现了NavigableSet接口。因此,ConcurrentSkipListSet是一个有序的集合。
- ConcurrentSkipListSet是