我有两个应用程序A和B,我需要修改B中来自A的数据库的数据(检查特定表中是否有新记录)。 我在 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);
}
}
}
关于java - Java中如何知道DB上是否有 Action ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57121672/