I am working on an Android application in which I allow the users to enter text as many time they want in a single minute. But the thread is not terminating after a minute. My code:

public void startTimer(View view) throws Exception {

```
    final Thread t = new Thread(new Runnable() {
        final Button myButton = (Button) findViewById(R.id.myButton);
        EditText mEdit = (EditText) findViewById(R.id.myTextInput);
        @Override
        public void run() {

            while (!Thread.currentThread().isInterrupted()) {
              myButton.setOnClickListener( 
                  new Button.OnClickListener() { 
                    public void onClick(View v) {
                                Log.d("Tag", mEdit.getText().toString());
                            }
                        }
                );
            }
        }
    });
    t.start();

    ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
    exec.schedule(new Runnable() {
        @Override
        public void run() {
            t.interrupt();
        }
    },1, TimeUnit.MINUTES);

}

```