If you do not put in onPause() isActive1 = false; when the application is minimized, onPause() and then onResume() and a new thread is created each time.
And if you put in onPause() isActive1 = false; a feeling that somehow does not work, it seems that when folding, pick up some other threads.
How to stop or delete a stream correctly when the application is in onPause() ?
@Override protected void onResume() { super.onResume(); isActive1 = true; Thread abcd = new Thread() { @Override public void run() { while (isActive1) { try { runOnUiThread(new Runnable() { @Override public void run() { //Код } }); Thread.sleep(100); //1000ms = 1 sec } catch (InterruptedException e) { e.printStackTrace(); } } } }; abcd.start(); @Override protected void onPause() { isActive1=false; super.onPause(); }