Where to Use Immutable Objects?
Immutable Objects Can Be Useful in Multi-Threaded Applications. Multiple Threads Can Act on Data Represented by Immutable Objects Without Concern of the Data...
Immutable objects can be useful in multi-threaded applications. Multiple threads can act on data represented by immutable objects without concern of the data being changed by other threads. Immutable objects are therefore considered more thread-safe than mutable objects.
What is the point of immutable objects?
Maximum reliance on immutable objects is widely accepted as a sound strategy for creating simple, reliable code. Immutable objects are particularly useful in concurrent applications. Since they cannot change state, they cannot be corrupted by thread interference or observed in an inconsistent state.
Which objects should be called immutable?
Immutable objects are simply objects whose state (the object's data) cannot change after construction. Examples of immutable objects from the JDK include String and Integer . Immutable objects greatly simplify your program, since they: are simple to construct, test, and use.