class DisPlaying extends Thread
{
public synchronized void displaying()
//一些操作
.....................
...................
while(flag==0)
{
try{Thread.sleep(1000);}catch(Exception e){}
}
{
public synchronized void displaying()
//一些操作
.....................
...................
while(flag==0)
{
try{Thread.sleep(1000);}catch(Exception e){}
}
如果在你线程中,资源同步要求比较高,还是用wait/notify比较好。
wait/notify这两者的关系,网上对它们的讲解有很多,你可以搜索。