title: Springboot: start a and stop programmatically a scheduled task
body: <p>I have two different tasks, let's call them A and B.</p>
  <p>Task A should start immediately (t0) and stop after a fixed time (t1), task B should start after a fixed time (t1) and run until i stop the service.</p>
  <p>Both task A and B should do something every x seconds (for convenience, print a string). I know that in Springboot i can achive that using this annotation:</p>
  <pre><code>@Scheduled(fixedDelay = 6000)
  private void taskA(){
     print(&quot;A&quot;)
  }
  
  </code></pre>
  <p>But i have no clue how to start and stop each tasks after the time window has passed.
  I have made a simple scheme to help you understand better.</p>
  <p><a href="https://i.stack.imgur.com/QEHZE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QEHZE.jpg" alt="enter image description here" /></a></p>
  <p>Thanks</p>