title: How to stop a scheduled task that was started using @Scheduled annotation?
body: <p>I have created a simple scheduled task using Spring Framework's <a href="https://docs.spring.io/spring-framework/docs/4.3.x/javadoc-api/org/springframework/scheduling/annotation/Scheduled.html" rel="noreferrer"><code>@Scheduled</code></a> annotation.</p>
  
  <pre><code> @Scheduled(fixedRate = 2000)
   public void doSomething() {}
  </code></pre>
  
  <p>Now I want to stop this task, when no longer needed.</p>
  
  <p>I know there could be one alternative to check one conditional flag at the start of this method, but this will not stop execution of this method.</p>
  
  <p>Is there anything Spring provides to stop <code>@Scheduled</code> task ?</p>