我的程序大概如下:
class DisPlaying extends Thread
{
public synchronized void displaying()
//一些操作
.....................
...................
while(flag==0)
{
wait();
}
//执行操作
.................
................
flag=0;
//执行操作
............... ..............
flag=1;
notifyAll();
}
public run()
{
displaying();
}
}
在主界面中通过菜单来启动在不同时刻来启动多个这样的线程,结果一旦进入wait(),线成阻塞,无法继续运行。似乎notifyAll()无法唤醒!为什么?是不是我这样做不对!高手帮我解决,谢谢!
class DisPlaying extends Thread
{
public synchronized void displaying()
//一些操作
.....................
...................
while(flag==0)
{
wait();
}
//执行操作
.................
................
flag=0;
//执行操作
............... ..............
flag=1;
notifyAll();
}
public run()
{
displaying();
}
}
在主界面中通过菜单来启动在不同时刻来启动多个这样的线程,结果一旦进入wait(),线成阻塞,无法继续运行。似乎notifyAll()无法唤醒!为什么?是不是我这样做不对!高手帮我解决,谢谢!
class DisPlaying extend Thread
{
public synchronized void displaying()
//一些操作
.....................
...................
while(flag==0)
{
wait();
}
//执行操作
.................
................