A hacker on a roll may be able to produce–in a period of a few months–something that a small development group (say, 7-8 people) would have a hard time getting together over a year. IBM used to report that certain programmers might be as much as 100 times as productive as other workers, or more. Peter Seebach


Language Java | Level Intermediate | Category Java collections framework (JCF) | 2015-07-22 20:41:14



ConcurrentSkipListMap is a scalable concurrent class which uses concurrent variant of SkipLists. It does not throw ConcurrentModificationException and support execute the operations safely from multiple threads. ConcurrentSkipListMap guarantees average O(log(n)) performance on a wide variety of operations.


Elements are fetched in natural order
Implements a concurrent variant of SkipLists. IT allows to access or update the items concurrently.
The Map.Entry reads from multiple threads and does not support update the value.
Does not permit the use of null keys or values.
Iterator that will never throw ConcurrentModificationException.

source Code


import java.util.Map;
import java.util.concurrent.ConcurrentNavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;

public class ConcurrentSkipListMapUse {

	public static void main(String[] args) {
		System.out.println("Insert elements to ConcurrentSkipListMap");
		 ConcurrentNavigableMap< String,String > concurrentSkipListMap = new ConcurrentSkipListMap< String,String >();
	        concurrentSkipListMap.put("3", "Java");
	        concurrentSkipListMap.put("2", "CPP");
	        concurrentSkipListMap.put("1", "C");
	        concurrentSkipListMap.put("5", "NodeJS");
	        concurrentSkipListMap.put("4", "CSharp");

	        System.out.println("Get the ceiling Entry of '2' : " + concurrentSkipListMap.ceilingEntry("2"));

	        ConcurrentNavigableMap< String, String > map = concurrentSkipListMap.descendingMap();
			for (Map.Entry< String, String > entry : map.entrySet()){
			    System.out.println(entry.getKey() + "/" + entry.getValue());

	        System.out.println("First Entry from ConcurrentSkipListMap: " + concurrentSkipListMap.firstEntry());
	        System.out.println("Last Entry  from ConcurrentSkipListMap: " + concurrentSkipListMap.lastEntry());
	        System.out.println("Poll Last Entry  from ConcurrentSkipListMap: " + concurrentSkipListMap.pollLastEntry());
	        System.out.println("Last Entry  from ConcurrentSkipListMap: " + concurrentSkipListMap.lastEntry());




Insert elements to ConcurrentSkipListMap
Get the ceiling Entry of '2' : 2=CPP
First Entry from ConcurrentSkipListMap: 1=C
Last Entry  from ConcurrentSkipListMap: 5=NodeJS
Poll Last Entry  from ConcurrentSkipListMap: 5=NodeJS
Last Entry  from ConcurrentSkipListMap: 4=CSharp


ConcurrentHashMap ConcurrentSkipListMap
Does not guarantee the runtime of its operations Guarantees average O(log(n)) performance
Does not allow null to be used as a key or value Null value and null keys are not allowed
Do not maintain insertion order Elements fetched in natural order
Support Only Serializable Support cloneable and Serializable
Do not support ceilingEntry, ceilingKey, firstEntry, floorEntry operations Support ceilingEntry, ceilingKey, firstEntry, floorEntry operations

When to use

If you need faster in-order traversal, and can afford the extra cost for insertion, use the SkipListMap.


Please login to add comments.