示例
public
static
class
ClassA {
Condition c;
boolean
flag;
public
void
methodA {
if
(flag) {
try
{
c.await();
}
catch
( Exception e ) {
}
//...
}
}
}
解决方案
将 await() 放入 while 循环内。
public
static
class
ClassA {
Condition c;
boolean
flag;
public
void
methodA {
while
(flag) {
try
{
c.await();
}
catch
( Exception e ) {
}
//...
}
}
}