long waitTime = nextReaction.get().getNextTime() - System.currentTimeMillis();
logger.debug(format("Time to wait for next Reaction: %d millseconds.", waitTime));
if (waitTime > 0) {
- synchronized (reactions) {
- try {
- logger.info(format("Waiting until %tc.", nextReaction.get().getNextTime()));
- reactions.wait(waitTime);
- } catch (InterruptedException ie1) {
- /* we’re looping! */
- }
- }
+ waitForNextReactionToStart(nextReaction, waitTime);
/* re-start loop to check for new reactions. */
continue;
}
}
+ private void waitForNextReactionToStart(Optional<NextReaction> nextReaction, long waitTime) {
+ synchronized (reactions) {
+ try {
+ logger.info(format("Waiting until %tc.", nextReaction.get().getNextTime()));
+ reactions.wait(waitTime);
+ } catch (InterruptedException ie1) {
+ /* we’re looping! */
+ }
+ }
+ }
+
private Optional<NextReaction> getNextReaction() {
while (isRunning()) {
synchronized (reactions) {