Hi i am new to java..
i am facing some problem in synchronization. problem is as follows:
I have a class A with two variables x and y and their getter and setter methods defined in the class.
Another class B makes an object O of class A and start two threads T1 and T2.
Both T1 and T2 can modify O.
How do i take care of synchronization here.
If i say synchronized keyword with getter and setter functions defined in class A then it does not make sure that if T1 is reading O.x then T2 does not modify O.x or O as a whole.
Keyword synchronized just make sure that same block of code or method is accessed by one thread at a time.
I hope this explains my doubt. If not then kindly let me know.
Thanks