class RES
{
private String name;
private String sex;
private boolean flat=false;
public synchronized void setname(String name,String sex)
{
if (flat)
{
try
{
this.wait();
}
catch (Exception e)
{}
}
else
{
this.name=name;
this.sex=sex;
}
flat=true;
this.notify();
}
public synchronized void getM()
{
if (!flat)
{ try
{
this.wait();
}
catch (Exception e)
{}
}
else
{ System.out.println(name+"......"+sex);
}
flat=false;
this.notify();
评论0
最新资源