|
In general, voytechs shows the general approach, you can syncryonize(this){} if the variable is in the class - which obviously it would have to be to be a get or set method.
That would be where your " if T1 is reading O.x then T2 does not modify O.x or O as a whole." question actually ends up. For practical, we can say the get and set only modifiy one variable so "shift the state of the class" - well that's what you just did by changing a variable.
If you have to have several things boogie together, then use what is called a Lock Object.
These can be idiot simple, they seem to work and are canonical code for synchronized.
|