class DisPlaying extends Thread
{
   public synchronized void displaying()
    //一些操作
      .....................
     
      ...................
   while(flag==0)
   {
     try{Thread.sleep(1000);}catch(Exception e){}
   }