在这种情况下,我必须检查数据库中的值,比如aValue。如果aValue可用,则执行进程aValueProcess()。如果该值不可用,我只能等待30分钟,并且需要每隔10分钟(3次)检查数据库中的值。如果超过30分钟,则退出程序。
有人能告诉我最好的方法是什么吗?任何帮助都是非常感谢的。
发布于 2010-08-10 05:15:48
下面是我散列的一些东西,它至少应该向你展示逻辑(注意,我做的大部分是c#,所以你可能不得不改变函数。
val aValue = aValueProcess();
int attempts = 0;
//Wait 10 minutes and try again if value is null and we have not tried
//3 times (30 minutes of trying)
while(aValue == null && attempts < 3)
{
thread.sleep(600000); //10 minutes in milliseconds
attempts += 1;
aValue = aValueProcess();
}https://stackoverflow.com/questions/3444215
复制相似问题