Make setters synchronized only
Changes to the object may not be visible to any reading thread, because JVM will not ensure that the reading thread's memory (like, cache) is in sync with the writing thread.
So, reader thread may still get out-of-date (older) values from its thread's cache than new value set by writing thread.
1.Make getters and setters both synchronized: No dirty read
When getters are synchronized, there will be lock on the object which will not allow other threads to modify the object state.
And synchronized also help to read the object from Main memory (not from cache) i.e NO DIRTY READ.
2.Use volatile keyword to ensure that the value has been read from Main memory.