public class TT1 implements Runnable { 
  int b = 100; 
  
  public synchronized void m1() throws Exception { 
      b = 1000;          (6)  
      Thread.sleep(5000);  (7)  // 这里程序阻塞 5000毫秒 
      System.out.println("b = " + b);  (12) 
  } 
    
  public synchronized void m2() throws Exception  { 
    Thread.sleep(2500);  (9)  // m2方法阻塞2500毫秒! 
    b = 2000;  (10)  // 因为阻塞时间 2500 <5000 所以 这个先自动释放,并执行 
  } 
  
  public void run() {    (4) //程序走run 方法 
    try { 
      m1();            (5)  // 调用m1()方法 
    } catch(Exception e)  { 
      e.printStackTrace(); 
    } 
  } 
  
  public static void main(String[] args) throws Exception  { 
    TT1 tt = new TT1();  (1) 
    Thread t = new Thread(tt);  (2) 
    t.start();    (3)  //启动线程 
  
    tt.m2();  (8)  // 因为m1线程阻塞, main方法也是个线程,它继续执行,调用m2方法 
    
    System.out.println(tt.b);  (11)  
  } 
  

 前天有个人贴了段程序在论坛上,我运行了一下结果是
2000
b=1000 可为什么别人说答案是
1000
b=1000 
 
有没有谁和我结果一样的!