Is there concurrent version for TreeMap and TreeSet in Java Collections Framework?

By | August 12, 2019

In this post we will discuss about Is there concurrent version for TreeMap and TreeSet in Java Collections Framework?

  • Java Collection Framework have ConcurrentSkipListMap and ConcurrentSkipListSet which are concurrent replacement for TreeMap and TreeSet. These classes implement SortedMap and SortedSet interface respectively.
  • if our application demands fair concurrency then instead of wrapping TreeMap and TreeSet inside synchronized collection, we can prefer these concurrent utilities.
  • These also implement NavigableMap and NavigableSet interface with methods like lowerKey, floorKey, ceilingKey, higherKey, headMap and tailMap.

Time Complexity

Average time complexity is log(n) for the containsKey, get, put and  remove operations of the ConcurrentSkipListMap

You may also like:

What are fail-fast and fail-safe Iterator?
What is difference between Iterator and LisIterator?
Why Prime Numbers are considered in writing certain algorithms like hashcode()?

That’s all about  Is there concurrent version for TreeMap and TreeSet in Java Collections Framework?
If you have any feedback or suggestion please feel free to drop in blow comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *