I've created an Employee
Object in Thread A. An Employee
class is mutable . In the same thread A, I've updated employee salary and change other fields. Then I put the object into a map and I do not access Employee
object from Thread A anymore.
Employee empl = new Employee("Jhon", 12000);
empl.setSalary(9000);
Map<String, Employee> employees = new ConcurrentHashMap<>();
And there is another Thread B, which constantly iterating over the map values in infinite loop and reading Employee salaries and other fields.
Is there any chances that Thread B will see the salary used when the object has been constructed (12000), not the updated one? (9000)
Please note, I do not update the same object from the different threads at the same time.