日期:2014-05-20 浏览次数:20636 次
public class TT implements Runnable{
public static void main(String[] args) throws Exception{
TT tt=new TT();
Thread t=new Thread(tt);
t.start();
Thread.sleep(2000);
tt.m2();
}
int b=100;
public synchronized void m1() throws Exception{
b=2000;
System.out.println("b1="+b);
Thread.sleep(5000);
System.out.println("b2="+b);
}
public void m2(){
b = 3000;
System.out.println(b);
}
public void run() {
try{
m1();
}
catch(Exception ex){
System.out.println(ex.getStackTrace());
}}
}