I have two threads. One invokes the update method of a class that modifies a variable. Another invokes the update method of a class that reads the variable. Only one thread
Use AtomicInteger or synchronize the access to be safe.
AtomicInteger
synchronize