Handler vs Thread

后端 未结 2 774
悲哀的现实
悲哀的现实 2021-02-08 02:39

I would like to know, once for all. I\'ve read in many places. When I want do some \'long time operations\' I should use a Handler.

But I don\'t get why? A

2条回答
  •  深忆病人
    2021-02-08 03:09

    It can't just be about getting you back to the UI thread since runOnUiThread(Runnable) does that very nicely. I suspect this is more about making it easier for Android to manage threads and other resources that shouldn't live outside of an Activity's context, and that the "Activity has leaked..." exceptions tell you when that's happened.

提交回复
热议问题