62,614
社区成员
发帖
与我相关
我的任务
分享
import java.util.*;
public class TT implements Runnable{
public int i =100;
public synchronized void m1(){
i=1000;
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("i="+i);
}
public void m2(){
i=2000;
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public void run() {
m1();
}
public static void main(String [] args){
TT tt = new TT();
Thread tr=new Thread(tt);
tr.start();
tt.m2();
}
}