title: Java - Pausing Akka Scheduler
body: <p>So I have this scheduler, which is not doing anything right now except incrementing a number . When it gets to 5, I want to pause it and afterwards reset the number <code>tries</code>. I get to the point where <code>totalTries</code> reached 5, and then it stops for 30 seconds. But after those 30 seconds have passed, it instantly logs the next 5 <code>totalTries</code> and pauses again. Clearly, something more is going on behind the curtains. </p>
  
  <p>Am I misunderstanding how this is used? What I want to do is pause the ActorSystem <code>system</code> entirely for that period of time. Any hints greatly appreciated.</p>
  
  <pre><code>system.scheduler().schedule(
      Duration.create(5, TimeUnit.SECONDS),
      Duration.create(1, TimeUnit.SECONDS),
      new Runnable() {            
  
          public void run() { 
  
                  int totalTries = incrementTries(1);
                  logger.info("tries: " + totalTries);
  
                  if(totalTries &gt;= 5) {
                      logger.info("5 tries reached, waiting 30 seconds.");                                
                      try {               
                          Thread.sleep(30000);
                      } catch (InterruptedException e) {
                          logger.info("Sleep interrupted" + e);
                      }
                      resetTries();
                  }                           
              }
          }
      }, system.dispatcher());
  </code></pre>