1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| private var threadInterrupt = false
override fun onDestroy() { Log.d("tag","onDestroy") threadInterrupt = true super.onDestroy() }
val thread = Thread(Runnable { for (i in 0..100) { val msg = weakHandler.obtainMessage() msg.obj = i msg.sendToTarget() Thread.sleep(3000)
if (threadInterrupt){ Log.d("tag","break") break } } }) thread.start()
|