Currently i am learning concurrency in java.
below is my doubt which i trying to explain here--
here i am fetching two object from datatase using their id.(using spring boot +hibernate)
object object1=getObjectFromDataBaseUsingId(id1);
object object2=getObjectFromDataBaseUsingId(id2);
- are both objects referencing the same object in heap if both id are same??
- in which case they will be always referencing the same object in heap.
when i checked it using some getter and setter method as explained below,i got that changes made in one object reflecting to other object.
//print any property of object2
print(object2.getSomething());
//change that property of object1
object1.setSomething(some value);
//again print that property of object2
print(object2.getSomething());
- what if we are fetching these objects in different-different thread ??. will same things apply here that changes made in one thread to this object will always reflect to other objects in different threads.
(please explain 4th doubt in more details and suggest some article about it)