有什么方法可以让 运行 异步任务以 15 秒为间隔持续到两分钟?
Is there any way to run Asynk task till two minutes in interval of 15 seconds?
我需要 运行 异步任务,直到每十五秒间隔两分钟。有什么办法吗?
像这样尝试
void TimerTask(int count)
{
if(count>8) // 8 cyclses,because 60*2/15
return;
Timer myTimer = new Timer(); // Create timer
myTimer.schedule(new TimerTask() {
@Override
public void run() {
// run your async task there
TimerTask(count++); //OnExecute
}
}, 0L, 15L * 1000);//every 15 sec (0L - seconds waiting for start)
}
`
调用它 - TimerTask(0);
我需要 运行 异步任务,直到每十五秒间隔两分钟。有什么办法吗?
像这样尝试
void TimerTask(int count)
{
if(count>8) // 8 cyclses,because 60*2/15
return;
Timer myTimer = new Timer(); // Create timer
myTimer.schedule(new TimerTask() {
@Override
public void run() {
// run your async task there
TimerTask(count++); //OnExecute
}
}, 0L, 15L * 1000);//every 15 sec (0L - seconds waiting for start)
}
` 调用它 - TimerTask(0);