我设置了一个计时器,在 1 小时间隔后在 SQL 中执行一些命令,但它运行了几次 4-5 次然后停止运行,尽管以更高间隔设置的其他计时器继续工作。会有什么问题?我在 nohup 中绝对没有错误。
public static void timer025() {
TimerTask t025 = new TimerTask() {
@Override
public void run() {
for (Client c : Load.api.getClients()) {
if (c.isRegularClient() && Load.PlayerExist(c.getUniqueIdentifier())) {
Load.api.sendPrivateMessage(c.getId(),
"[b]123[/b]");
mysql.update("UPDATE game SET coins = coins+0.25 WHERE game.clientid = '"
+ c.getUniqueIdentifier() + "'");
}
}
}
};
TimerTask t026 = new TimerTask() {
@Override
public void run() {
for (Client c : Load.api.getClients()) {
if (c.isRegularClient() && Load.PlayerExist(c.getUniqueIdentifier())) {
if (c.getChannelId() == 1238292) {
Load.api.sendPrivateMessage(c.getId(),
"[b]1234");
mysql.update("UPDATE game SET coins = coins+300 WHERE game.clientid = '"
+ c.getUniqueIdentifier() + "'");
} else {
Load.api.sendPrivateMessage(c.getId(),
"[b]12345[/b]");
mysql.update("UPDATE game SET coins = coins+150 WHERE game.clientid = '"
+ c.getUniqueIdentifier() + "'");
}
}
}
int client = api.getServerInfo().getClientsOnline();
int ret = 200 * client;
mysql.update("UPDATE wallet SET coins = coins-" + ret + " WHERE wallet.uswall = 'mainwall'");
}
};
Timer t = new Timer();
t.schedule(t025, 1000 * 60 * 15, 1000 * 60 * 15);
t.schedule(t026, 1000 * 60 * 60, 1000 * 60 * 60);
}