View Single Post
  #6 (permalink)  
Old 11-27-2008, 12:30 AM
Nicholas Jordan's Avatar
Nicholas Jordan Nicholas Jordan is offline
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 1,018
Rep Power: 3
Nicholas Jordan is on a distinguished road
Default
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.
__________________
Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Reply With Quote