If you wish to access the same variable from more than one thread, you will need to use the synchronized keyword to ensure that accesses to the variable are performed correctly. You can control access either by means of a synchronized statement or by using synchronized methods. An example of the use of synchronized methods is:
0820: public class Store {
0821: public Store(int vStore) { iStore = vStore; }
0822: public synchronized int get() { ... return iStore; }
0823: public synchronized void put(int vStore) { iStore = vStore; ... }
0824: ...
0825: private int iStore;
0826: }