title: Schedule task to run 3 times a day for X minutes and if
body: <p>Below is a sample of the code I was trying, I need to run 1 task in 3 different times for X minutes every day and let's say I have 12,17,20 and it should run for 120 minutes and it is already 12:30:00 so if i open the application it should start the task and it should run for 90 minutes.</p>
  
  <p><strong>What am I doing wrong here and what do I have to change in order to do the above ?</strong></p>
  
  <pre><code>    // here I receive my config with the hours I need to run my task
      String[] time = Config.SCHEDULE.split(",");
      int runTimeLeft = Config.TIMELEFT;
      for (String hour : time)
      {
          Calendar calendar = Calendar.getInstance();
          calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hour));
          calendar.set(Calendar.MINUTE, 0);
          calendar.set(Calendar.SECOND, 0);
  
          long start = calendar.getTimeInMillis() - System.currentTimeMillis();
          ThreadPoolManager.getInstance().scheduleAtFixedRate(new Runnable()
          {
              public void run()
              {
                  startMyTask();
              }
          }, start, 24 * 60 * 60 * 1000);
      }
  </code></pre>