Android: RunOnUiThread vs AsyncTask

前端 未结 5 1041
渐次进展
渐次进展 2020-12-01 00:50

I believe Google suggests developers to use AsyncTask. However, I would like to know how is it different from using \'new Thread\' and then calling \'RunOnUiThread\' in perf

5条回答
  •  無奈伤痛
    2020-12-01 01:37

    According to this, AsyncTask is easier to use, but has some limitations like the following:

    • Core pool size and Work queue is fixed: 5 pools / 10 elements
      • it's hard coded and can't be changed
    • Thread priority is fixed to low
    • Exception handling is not as well supported as with Thread

    Also there will be another difference that I haven't figured out. You can find and inspect full source code of AsyncTask since Android is opensource :-)

    Have a good time with coding in Android!

提交回复
热议问题