public class TT implements Runnable{

int b = 100;

public synchronized void m1() throws Exception {
System.out.println("执行m1");
System.out.println("m1默认优先级是"+Thread.currentThread().getPriority());
b= 1000;
Thread.sleep(7000);
System.out.println("b="+b);
}

public synchronized void m2() throws Exception {
System.out.println("执行m2");
System.out.println("m2默认优先级是"+Thread.currentThread().getPriority());
Thread.sleep(2500);
b= 2000;
//System.out.println("b="+b);
}

@Override
public void run() {
try {
m1();
} catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) throws Exception {
System.out.println("main默认优先级是"+Thread.currentThread().getPriority());
TT tt= new TT();
Thread t = new Thread(tt);
t.start();
System.out.println("111111111111");
tt.m2();
System.out.println(tt.b);
}


}为什么 打印先打印 执行m2 而不是 m1
打印结果测试多次 明明有5秒的时间差了
1000
b = 1000  这个出现概率小2000 
b =2000  这个出现概率大