0 Replies Latest reply: Feb 16, 2012 12:15 PM by 918065 RSS

    ScheduledThreadPoolExecutor.schedule(aTask) Some tasks fail quietly.


      I have the following code:

      public void put(Token token) {
      // ...
      // implements Runnable (of course)
      TokenAnnihilator tokenAnnihilator = new TokenAnnihilator(tokenStore, token);

      tokenAnnihilator, tokenTimeToLiveSeconds * 1000, TimeUnit.MILLISECONDS
      // ...

      put(Token token) gets called often and I am finding that under load only some of the tasks are executed. Some fail quietly or so it would seem.

      I expect my implementation is naive and I need to do some buffering of the tasks, or otherwise handle the tasks differently.

      I have two questions specifically:

      1) How do I diagnose why only some of my tasks are running? They currently fail quietly.

      2) If I find out that the cause is queue saturation, could I create a buffer (perhaps a List of tasks to run) and then wrap that in Runnable to then hand off to the executor? If I did this say every 100ms it would reduce the number of tasks to 10 per second although each tasks would end up having to do a lot more work when executed.