Java Synchronization inside Another Thread
<p>I have a quick question about Java synchronization.</p>

<p>Please assume the following code:</p>

<pre><code>public class Test {
    private String address;
    private int age;

    public synchronized setAddress(String a) {
        address = a;
    }

    public synchronized setAge(int a) {
        age = a;
    }

    public synchronized void start() {
          ...

          listener = new Thread(new Runnable(){
              public void run() {
                      ...
                  setAge(10);
                      ...

                  synchronized(Test.this) {
                      address = null;
                  }
              }
          }
    }
}
</code></pre>

<p>I am a little bit unsure about Java synchronization when synchronized method or synchronized block is called inside another thread.</p>

<p>Assume the thread running class Test as A, and
the listener thread B.</p>

<p>Then if I execute the code above, does it guarantee that synchronized method calls and synchronized block are synchronized with the A (the thread running Test class) ?</p>

<p>Thank you for reading.</p>
