title: Stopping a running void in java
body: <p>What's the way to stop a running method in Java?</p>
  <p>I have a method called <code>main</code> in my <code>MainActivity.java</code> file and also I have two methods into it. They are blink() [which is a forever loop] and stop() . after a button(id=btn1) clicked I call the method blink() and I have an another button (id=btn2), on clicking on this button It will call the method stop(). Now I want that when ever i click on the button(btn2) the running method blink() will be stopped exactly on that moment.</p>
  <p>What I actually need is -</p>
  <pre><code>public class MainActivity extends Activity {
      TextView tv1;
      Button btn;
      
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          @Override
          public void onClick(View _view) {
              _blink();
          }
  
          @Override
          public void onClick(View _view) {
              _stop();
          } 
  
          public void _blink() {
              // Here is my code which I want to perform as a forever loop
          }
  
          public void _stop() {
              //here I want the code which will stop the running method blink()
          }
      }
  }
  </code></pre>