Android注释中MainThread,UiThread,WorkerThread,BinderThread之间的区别

Ali*_*iSh 5 binding multithreading android annotations android-support-library

正如我在线程文档的android注释中读到的那样

我们有四种类型的线程,

  • @MainThread
  • @UiThread
  • @WorkerThread
  • @BinderThread

有什么区别?

Ali*_*iSh 9

不同之处是:

  • @MainThread,应用程序启动时首次运行Thread,
  • @UiThread,从MainThread运行UI工作,
  • @WorkerThread,在程序员定义线程时运行
  • @BinderThread,用于ContentProvider中的query()/ insert()/ update()/ delete()方法.

  • 该过程中只有一个主线程.那是MainThread.该线程也是UiThread.例如,该线程是活动的主窗口运行的.但是,应用程序也可以创建运行不同窗口的其他线程.这将是非常罕见的; 这个区别最重要的是系统过程.通常,您需要使用MainThread注释与生命周期关联的方法,以及使用UiThread关联视图层次结构的方法. (3认同)