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

Getting ready

A collection can be synchronized if you apply one of the Collections.synchronizeXYZ() methods to it; here, we have used XYZ as a placeholder that represents either Set, List, Map, or one of the several collection types (see the API of the Collections class). We have already mentioned that the synchronization applies to the collection itself, not to its iterator or the collection members. 

Such synchronized collections are also called wrappers because all of the functionality is still provided by the collections passed as parameters to the Collections.synchronizeXYZ() methods, so the wrappers provide only thread-safe access to them. The same effect could be achieved by acquiring a lock on the original collection. Obviously, such ...

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