Showing posts with label Concurrent. Show all posts
Showing posts with label Concurrent. Show all posts

Friday, August 9, 2019

Java ConcurrentSkipListSet Examples

1. Overview


In this tutorial, We'll guide to the new Java 1.6 version ConcurrentSkipListSet. This is part of the new Collection API and package java.util.concurrent.

This class is a direct subclass of AbstractSet and implements NavigableSet.

public class ConcurrentSkipListSet<E> extends AbstractSet<E> implements NavigableSet<E>, Cloneable, Serializable


ConcurrentSkipListSet is mainly used to keep the elements sorted according to their natural ordering. This is the default behavior and no need to provide the comparator logic to it. If we provide the Comparator at the time of constructor creation then it uses our logic to sort the set. ConcurrentSkipListSet internally built using ConcurrentSkipListMap. This is equivalent to TreeSet and works well in a concurrent environment.