Is this a prefect way to stop handlerthread?

后端 未结 4 1953
你的背包
你的背包 2020-12-31 08:35

I always create two handler: one is wraping on main thread, another is wraping on a single thread.

Is this a best method to start and stop these in an Activity lifec

4条回答
  •  萌比男神i
    2020-12-31 09:26

    You can use this as a safe way to stop threads:

     if (safeThread!= null) {
         safeThread.quit();
         safeThread = null; // Object is no more required.
     }
    

    You can use safeThread.quitsafely as well.

提交回复
热议问题