Considering the following code snippet:
Object bar1 = new ... ;
Object bar2 = new ... ;
Object foo = (either bar1 or bar2) ;
Now, foo can be either bar1 or bar2 at various times of the programs. I just wanted to check that synchronized(foo) will lock the corresponding bar1 or bar2. This seems like the most likely scenario given that objects aren't copied in Java. Is this correct?