1 2 class T1528rc3 extends Thread { 3 private static int i = 0; 4 public static void main(String [] args) { 5 synchronized ("foo" + "bar") { 6 System.out.print("1 "); 11 new T1528rc3().start(); try { 13 sleep(500); } catch (InterruptedException e) { 15 } 16 if (i == 2) 17 System.out.println(" Constant not inlined; wrong object locked "); 18 else if (i == 0) 19 System.out.println(" Indeterminate - thread never ran "); 20 else if (i == 1) 21 System.out.print("3 "); 22 else 23 System.out.println(" Unexpected result "); 24 } 25 } 26 public void run() { 27 System.out.print("2 "); 28 i = 1; 29 synchronized ("foobar") { 30 i = 2; 31 } 32 System.out.print("4"); 33 } 34 } 35 | Popular Tags |