class A extends Thread
{
B b;
public void A(B b){
this.b=b;
}
public void run(){
synchronized(this)
{
System.out.println(getName()+"方法开始停止");
try
{
sleep(5000);
}
catch (Exception e)
{
}
System.out.println(getName()+"方法重新运行");
}
}
public static void main(String[] args)
{
B obj=new B();
A obj1=new A(obj);
A obj2=new A(obj);
obj1.start();
obj2.start();
}
}
class B
{
}