Let say i have following code
int i =0;
setvalue(int i){this.i = i}
getvalue(){return i}
Now 200 thread calling setValue
with random[a...b] number.
And 200 thread calling getValue
Now what all values will be seen by thread calling getValue:
- Is it possible to see a value which is not in [a...b] set?
- Is it guaranteed to see values only in set [a...b]? If yes some underlying info will be helpfull.
- Behaviour is not defined by jvm?
- Will the behaviour changes for long/ double/ String/
referenceToAObject
?
EDIT:
I am interested in referenceToAObject
, that is if instead of int i
, we have Object i
in above sample, So basic question is reference updation atomic in nature ?