android 中两个线程同时运行,第一个线程每隔一分钟运行一次,第二个线程每隔半分钟运行一次如何实现?
2个回答
展开全部
伪码:
uint oldTime = getCurrentTime();
bool continueRunnint = true;
while( continueRunning ) {
while(true) {
currentTime = getCurrentTime();
if (currentTime - oldTime > 60sec) break;
oldTime = currentTime;
sleep(1 second);
}
runningYourCodeHere();
if (yourDone) continueRunning = false;
}
uint oldTime = getCurrentTime();
bool continueRunnint = true;
while( continueRunning ) {
while(true) {
currentTime = getCurrentTime();
if (currentTime - oldTime > 60sec) break;
oldTime = currentTime;
sleep(1 second);
}
runningYourCodeHere();
if (yourDone) continueRunning = false;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询