Say I have a global object:
class Global { public static int remoteNumber = 0; }
There is a thread runs periodically to get new number f
Read threads can read old value for undetermined time, but in practice there no problem. Its because each thread has own copy of this variable. Sometimes they sync. You can use volatile keyword to remove this optimisation:
public static volatile int remoteNumber = 0;