class A extends
Thread {
String[] sa;
public A(String[] sa) {this.sa = sa;}
public void run() {
synchronized (sa) {System.out.print(sa[0] + sa[1] + sa[2]);}
}}
class B {
private static String[] sa = new String[]{"X","Y","Z"};
public static void main (String[] args) {
synchronized (sa) {
Thread t1 = new A(sa); t1.start();
sa[0] = "A"; sa[1] = "B"; sa[2] = "C";
}}}
The output here is ABC and the explanation is that the t1 thread will be blocked until main method execution completes.I agree that the t1 thread is invoking a block synchronised on sa but that block is in a different class i.e class A???