iPhone在不接数据线并锁屏后,短时间内就会自动进入系统休眠状态(kIOMessageCanSystemSleep),这种状态下的所有(可能有例外)进程均被挂起。在唤醒系统后,会接着继续运行。
例如:
后台程序
int main()
{
int i = 0;
FILE *fout;
fout = fopen("1.log", "a");
while(1)
{
sleep(1);
fprintf("%d:%d\n", time(NULL), i++);
}
fclose(fout);
return 0;
}
日志中的结果是,时间是不连续的,而i是连续的。