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