If you declare a member variable as volatile in Java, does this mean that all the object's data is stored in volatile memory, or that the reference to the object is stored in volatile memory?
For example if I have the following class:
class C{
int i = 0;
char c = 'c';
}
If I declare an instance of it as follows:
private volatile C obj;
does that store the reference to obj
in volatile memory, or obj
's data (obj.i
and obj.c
) in volatile
memory?
Does it make obj.c
and obj.i
thread safe or not?