I have boolean field:
private boolean isReady = false;
private boolean isReady() {
return isReady;
}
and I am using it inside two methods:
synchronized (topologyLock)
{
try
{
while(!instance.isReady())
{
topologyLock.wait();
}
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
private synchronized boolean topologyChanged()
{
synchronized(topologyLock)
{
isReady = true;
topologyLock.notifyAll();
}
}
I think that above code should work perfectly - or do I need to make this boolean variable volatile?