static class CommitTimer extends TimerTask {
@Override
public void run() {
commitLock.lock();
try {
doSome(0);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
commitLock.unlock();
}
}
}
Timer timer = new Timer();
timer.schedule(new CommitTimer(), 10 * 1000, 5*60* 1000);