title: Which one of these two methods should I use to stop correctly a scheduled thread?
body: <p>I created a simple task, to run every two minutes, that I want to stop once a boolean becomes true.</p>
  
  <pre><code>ScheduledExecutorService scheduledxecutor = Executors.newScheduledThreadPool(1);
  
  ScheduledFuture&lt;?&gt; scheduledFuture = scheduledExecutor.scheduleAtFixedRate(drawRunnable , 0, 2, TimeUnit.MINUTES);
  </code></pre>
  
  <p>I've been lurking around stackoverflow and I basically found that I need to use either <code>scheduledFuture.cancel(false)</code> or <code>scheduledExecutor.shutdown()</code>. </p>
  
  <p>Which one should I use? </p>