且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当将Android停止它的CPU没有唤醒锁?

更新时间:2022-06-23 05:12:49

解答您所有的子问题

  1. Android的睡在没有唤醒锁是活动的。这不要紧,进程和线程运行它仍然会睡觉。这意味着,如果你的线程或其他进程那里还没有激活唤醒锁定您的线程将不会被执行,因此不会耗尽所有电池。只有当其他一些进程获取一个wakelock的线程将被激活。

  1. Android sleeps when no wake-lock is active. It does not matter what processes and threads are running it will still sleep. That means if your thread or some other process out there has not activated a wake lock your thread will not execute and hence will not drain any battery. The thread will be made active only when some other process acquires a wakelock.

同样适用于Timer.schedule()。假设你编写一个执行的每一秒,但没有任何唤醒锁定一个计时器,并说机器人进入睡眠状态,持续10秒。当它醒来P的11秒它会识别你的计时器已经过期10次便索性放弃九城实例并执行它只有一次。如果你想非常可靠的计时器,你将不得不要么得到一个唤醒锁或用户AlarmTimer。

Same is applicable to the Timer.schedule(). Say you write a Timer that executes every second but without any wake-lock, and say android goes to sleep for 10 seconds. When it wakes p on 11th second it will identify that your timer has expired 10 times it will simply discard the9 instances and execute it only once. If you want very reliable timers you will have to either obtain a wake lock or user AlarmTimer.

是的。