TheFearow/Phate already built this in with Scape-Rune 
Code:
while(!shutdownServer) {
try{
playerHandler.process(); npcHandler.process(); itemHandler.process();
} catch(Exception e) { }
sPointRound += 1;
if (sPointRound == 2) { sPointRound = 0; spawnPointManager.process(); }
/*if (cycle == 1200)
{
restartServerOne();
}
if (cycle == 1202)
{
restartServerTwo();
}*/
long timeSpent = System.currentTimeMillis()-lastTicks;
totalTimeSpentProcessing += timeSpent;
if(timeSpent >= cycleTime) {
timeSpent = cycleTime;
//if(++waitFails > 100) { shutdownServer = true;
//misc.printlnTag("Restart your computer"); }
}
try { Thread.sleep(cycleTime-timeSpent); } catch(java.lang.Exception _ex) { }
lastTicks = System.currentTimeMillis(); cycle ++;
if(cycle % 100 == 0) {
float time = ((float)totalTimeSpentProcessing)/cycle; }
}
Database.destroyConnection(); shutdownServer = true; playerHandler.destruct(); clientHandler.killServer(); clientHandler = null; main(null);
}