0
我有一种情况,我必须检查数据库中的值,如aValue。 如果aValue可用,则执行aValueProcess()。 如果该值不可用,我只能等待30分钟,并且需要每10分钟检查一次数据库的值(3次)。 如果超过30分钟退出程序。定期连接数据库
任何人都可以给我最好的方法来做到这一点。任何帮助表示赞赏。
我有一种情况,我必须检查数据库中的值,如aValue。 如果aValue可用,则执行aValueProcess()。 如果该值不可用,我只能等待30分钟,并且需要每10分钟检查一次数据库的值(3次)。 如果超过30分钟退出程序。定期连接数据库
任何人都可以给我最好的方法来做到这一点。任何帮助表示赞赏。
这里是我散列这至少应该告诉你的逻辑(注意我做大多数是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();
}