我想知道是否有必要在这个线程上调用一些取消机制,或者它是否会在 countDowntimer 为空后停止?让我们看一下我创建的运行 android countdownTimer 的线程:
val myTimer :CountDownTimer? = null
Thread {
Looper.prepare()
myTimer = object : CountDownTimer(30000L, 1000L) {
override fun onTick(millisUntilFinished: Long) {
this@MainActivity.runOnUiThread {
Log.v("mytag", "${Thread.currentThread().name}")
Log.v("mytag", "$millisUntilFinished")
}
}
override fun onFinish() {
}
}.start()
Looper.loop()
}.start()
//later on i will cancel the timer like this:
myTimer.cancel
myTimer = null
do i need to do anything else to this thread to clean it up after that ?