title: Scheduling: execute tasks only one time in spring boot
body: <p>Im trying to manage scheduled tasks using spring boot. I want to execute my job <strong>only one time at a particular date</strong> ( specified by the user ). User can add dates for execution as much as he wants.Here is my Job : </p>
  
  <pre><code>@Component
  public class JobScheduler{
  
      @Autowired
      ServiceLayer service;
  
      @PostConstruct
      public void executeJob(){
          try {
              service.execute();
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
      }
  }
  </code></pre>
  
  <p>And here is the execute method : </p>
  
  <pre><code>private TaskScheduler scheduler;
  
  Runnable exampleRunnable = new Runnable(){
      @Override
      public void run() {
          System.out.println("do something ...");
      }
  };
  
  @Override
      @Async
      public void execute() throws Exception {
          try {
  
              List&lt;Date&gt; myListOfDates = getExecutionTime();  // call dao to get dates insered by the user
  
              ScheduledExecutorService localExecutor = Executors.newSingleThreadScheduledExecutor();
              scheduler = new ConcurrentTaskScheduler(localExecutor);
              for(Date d : myListOfDates ){
              scheduler.schedule(exampleRunnable, d);
              }
  
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
      }
  </code></pre>
  
  <p>Issue 1 : Im using PostConstruct annotation. Thus, when executeJob method is called, there is no dates in the List 'myListOfDates'.</p>
  
  <p>Issue 2 : Supposing that myListOfDates contains dates, how can i get the latest dates in case user entered another one? </p>
  
  <p>Issue 3 : If i use @Scheduled(initailDelay=10000, fixedRate=20000) instead of @PostConstruct annotation, it will resolve the first issue, but it will execute my job every 20s for instance.</p>
  
  <p>Any clue ?</p>