Mutability is a source of bugs in multi-threaded applications. A mutable bug is normally a data bug caused by values being updated and shared between threads. To remove the risk of mutability bugs, it is best to use immutable types. The guaranteed safe execution of a body of code by multiple threads at the same time is called thread safety. When working with multi-threaded programs, it is important that your code is thread-safe. Your code is thread-safe if it removes race conditions and deadlocks, along with problems caused by mutability.
An object that cannot be modified after it has been created is an immutable object. Once created, if passed between threads using correct thread synchronization, all threads will see the same valid state of an object. Immutable objects allow you to share data safely between threads.
An object that can be modified after it has been created is a mutable object. Mutable objects can have...