我有两个应用程序A和B,我需要修改B中来自A的DB的数据(检查特定表中是否有新记录)。
我对B进行了无限循环,但是我认为这不是最佳解决方案。
int i = 0;
for(;;)
{
for(i = 0; i <= 600000;)
{
i++;
}
//Check if there is a new record in a table from app A.
String raw_xml = B.checkDB();
//if there is a new record in a table from app do the
// function doPingTest ()
if (raw_xml!= null)
{
new TestB().doPingTest(raw_xml);
}
i = 0;
}
最佳答案
在使用其他替代方法进行了一些测试之后,这是最好的解决方案:
for(;;)
{
while(true)
{
//sleep one minute
Thread.sleep(60 * 1000);
//Check if there is a new record in the DB
String raw_xml = B.checkDB();
if (raw_xml!= null)
{
new TestB().doPingTest(raw_xml);
}
}
}