if (_expirationTime == 0)
_expirationTime = Long.MAX_VALUE;
if (now - _suspendedDuration > _expirationTime) {
_state = STATE_EXPIRED;
throw new TaskEndedException("Expired");
}
if (_stop.get()) {
_state = STATE_ENDED;
throw new TaskEndedException("Stopped");
}
if (_suspend.get()) {
while (_suspend.get()) {
if (_stop.get()) {
_state = STATE_ENDED;
throw new TaskEndedException("Stopped");
}
_state = STATE_SUSPENDED;
try {
Util.sleep(Persistit.SHORT_DELAY);
} catch (final PersistitInterruptedException ie) {
throw new TaskEndedException("Interrupted");
}
}
_suspendedDuration += (System.currentTimeMillis() - now);
_state = STATE_RUNNING;
}