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 concurrency problem most often occurs when different threads modify and read data from the same shared resource. Decreasing the number of modifying operations diminishes the risk of concurrency issues. This is where immutability--the condition of read-only values--enters the stage. 

Object immutability means an absence of means to change its state after the object has been created. It does not guarantee thread safety but helps to increase it significantly and provide sufficient protection from concurrency problems in many practical applications. 

Creating a new object instead of reusing an existing one (by changing its state via setters and getters) is often perceived as an expensive approach. But with the power of modern ...

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