RunThreadExampleRepeat Every 6 second, delay 1 secondTimertimer = newTimer(); timer.scheduleAtFixedRate(newTimerTask() { @Overridepublicvoidrun() { Toast.makeText(MainActivity.this, "Coba", Toast.LENGTH_SHORT).show(); } }, 1000, 6000);Run Thread UIrunOnUiThread (newThread(newRunnable() { publicvoidrun() { Toast.makeText(MainActivity.this, "Coba", Toast.LENGTH_SHORT).show(); } }));Run Thread No UIThreadtimer = newThread(){ publicvoidrun(){ try{ sleep(1000); } catch (Exceptione) { e.printStackTrace(); } finally { //Toast.makeText(MainActivity.this, "Coba", Toast.LENGTH_SHORT).show();Log.d(getClass().getSimpleName(), "onCreate: "); } } }; timer.start();Run Thread No UI Delay 4 secondnewHandler().postDelayed(newRunnable() { @Overridepublicvoidrun() { //Toast.makeText(MainActivity.this, "Coba", Toast.LENGTH_SHORT).show();Log.d(getClass().getSimpleName(), "onCreate: "); } }, 4000);Copyright 2021 M. Fadli Zein