in commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheMonitor.java [134:196]
public void run()
{
do
{
if ( allright.get() )
{
log.debug( "ERROR DRIVEN MODE: allright = true, cache monitor will wait for an error." );
}
else
{
log.debug( "ERROR DRIVEN MODE: allright = false cache monitor running." );
}
if ( allright.get() )
{
// Failure driven mode.
try
{
lock.lock();
trigger.await();
// wake up only if there is an error.
}
catch ( final InterruptedException ignore )
{
//no op, this is expected
}
finally
{
lock.unlock();
}
}
// check for requested shutdown
if ( shutdown.get() )
{
log.info( "Shutting down cache monitor" );
dispose();
return;
}
// The "allright" flag must be false here.
// Simply presume we can fix all the errors until proven otherwise.
allright.set(true);
log.debug( "Cache monitor running." );
doWork();
try
{
// don't want to sleep after waking from an error
// run immediately and sleep here.
log.debug( "Cache monitor sleeping for {0} between runs.", idlePeriod );
Thread.sleep( idlePeriod );
}
catch ( final InterruptedException ex )
{
// ignore;
}
}
while ( true );
}