Does synchronized work on referenced/pointer variables?
<p>So I know how synchronize keyword works in general but would the below work as I think it would work (ie two threads will not step on eachother's toes while adding or removing) </p>

<pre><code>public MyClass myClass = new MyClass();
public MyClass2 myClass2 = new MyClass2();

public class MyClass {
     private ArrayList&lt;String&gt; myString = new ArrayList&lt;String&gt;();

     public ArrayList&lt;String&gt; GetArrayList() {
         return myString;
     }
     public MyClass() {
          new Thread(new Runnable {
               public void run() {
                   synchronized(myString) {
                       /* add or remove myString elements */
                   }
               }
          }).start();
     }

}


public class MyClass2 {
     // Pointer to myString
     ArrayList&lt;String&gt; refString;
     public MyClass2() {
          refString = myClass.GetArrayList();
          new Thread(new Runnable {
               public void run() {
                   synchronized(refString) {
                       /* add or remove refString elements */
                   }
               }
          }).start();
     }
     }
}
</code></pre>

<p>EDIT: next time i'll type this out in eclipse and copy&amp;paste :)</p>
