实际想输出zhangsan:fale
          lisi:female
可是总是输出zhangsan:falei=(i+1)%2;这里应该怎么改呢?或者还有其它的吗?class Produce implements Runnable
{
Q q;
public Produce(Q q)
{
   this.q=q;
}
public void run()
{
int i=0;
while(true)
{
synchronized(q)
{
if(i==0)
  {
  q.name="zhangsan";
  try{Thread.sleep(1);}catch(Exception e){}
    q.sex="fale";
    }
  else
    {
      q.name="lisi";
      q.sex="female"; 
    }      
  }  
  i = (i+1)%2;
  }
}
}
class Customer implements Runnable
{
Q q;
public Customer(Q q)
{
  this.q=q;
}
public void run()
{

{
  while(true)
  {
     synchronized(q)
     {
            System.out.print(q.name);
            System.out.println(":"+q.sex);
        }
  }
  }
}
}
class Q
{
   String name="unknow";
   String sex="unknow";
}
class Test55
{
public static void main(String[] args)
{
 Q q=new Q();
 new Thread(new Produce(q)).start();
 new Thread(new Customer(q)).start();
}
}