title: How to stop the timer after certain time?
body: <p>I have an android application which has a timer to run a task:</p>
  
  <pre><code>time2.scheduleAtFixedRate(new TimerTask() {
          @Override
          public void run() {
              sendSamples();
          }
      }, sampling_interval, sending_interval);
  </code></pre>
  
  <p>Lets say sampling_interval is 2000 and sending_interval is 4000. </p>
  
  <p>So in this application I send some reading values from a sensor to the server. But I want to stop the sending after 10000 (10 seconds).</p>
  
  <p>What should I do?</p>