Reputation: 11
I set a timer to do some commands in SQL after a 1-hour interval, but it runs a few times 4-5 and then stops running, although other timers set at higher intervals continue to work. What would be the problem? I have absolutely no error in 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);
}
Upvotes: 0
Views: 36