Does a Thread launched by Activity continue running once the device goes to sleep?

*爱你&永不变心* 提交于 2019-12-13 12:52:12

问题


This is somewhat similar to App seems to stop working when the screen goes to sleep however they discuss an AsyncTask while in my situation it is a plain Thread.

So let's say an activity starts a Thread, and then the phone goes to sleep, does the thread continue execution?


回答1:


Not unless you have a wakelock. (It does continue to run if your activity goes to the background, but might be killed at any time the foreground activity requires more resources.)



来源:https://stackoverflow.com/questions/7379880/does-a-thread-launched-by-activity-continue-running-once-the-device-goes-to-slee

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!