O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

Before we select which collections to use, read the Javadoc and see whether the limitations of the collection are acceptable for your application.

For example, as per the Javadoc, the CopyOnWriteArrayList class is ordinarily too costly, but may be more efficient than alternatives when traversal operations vastly outnumber mutations, and is useful when you cannot or don't want to synchronize traversals, yet need to preclude interference among concurrent threads. Use it when you do not need to add new elements at different positions and do not require sorting. Otherwise, use ConcurrentSkipListSet.

The ConcurrentSkipListSet and ConcurrentSkipListMap classes, as per the Javadoc, provide expected average log(n) time cost for the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required