In a thread-safe class, all field accesses that can be caused by calls to public methods must be properly synchronized.

Protect the field access with a lock. Alternatively mark the field as volatile if the write operation is atomic. You can also choose to use a data type that guarantees atomic access. If the field is immutable, mark it as final.

  • Java Language Specification, chapter 17: Threads and Locks.
  • Java concurrency package: java.util.concurrent.