Java Utililty Methods Timer Usage

List of utility methods to do Timer Usage

Description

The list of methods to do Timer Usage are organized into topic(s).

Method

intcountWorkerPoolTimerThreads()
count Worker Pool Timer Threads
return countThreads(WORKER_POOL_TIMER);
TimerdelayedExit(final int status, final long delay)
delayed Exit
Timer timer = new Timer();
timer.schedule(new TimerTask() {
    public void run() {
        System.exit(0);
}, delay);
return timer;
voidexitSystemAfterTimeout(final long delay)
exit System After Timeout
new Timer().schedule(new TimerTask() {
    @Override
    public void run() {
        System.exit(1);
}, delay);
TimergetMinIdleTimer()
Get the Timer for checking keyedPool's idle count.
if (MIN_IDLE_TIMER == null) {
    MIN_IDLE_TIMER = new Timer(true);
return MIN_IDLE_TIMER;
TimergetQuickSearchTimer()
get Quick Search Timer
if (quickSearchTimer == null) {
    quickSearchTimer = new Timer("QuickSearchTimer", true);
return quickSearchTimer;
TimergetSlowTimer()
get Slow Timer
synchronized (TIMER_LOCK) {
    if (timerslow == null) {
        timerslow = new Timer();
    return timerslow;
TimergetTimer(String id)
get Timer
Timer timer = timerById.get(id);
if (null == timer) {
    timer = new Timer(true);
    timerById.put(id, timer);
return timer;
booleanmayNewTasksBeScheduled(Timer timer)
Checks whether new tasks can be scheduled, that is whether the time thread is still active.
try {
    timer.schedule(null, 0);
} catch (IllegalStateException ex) {
    return false;
} catch (NullPointerException ex) {
    return true;
return true;
...
voidprintLoadToConsole(int milliOffset)
Prints a spinning icon to the console
loading = true;
final Timer t = new Timer();
TimerTask task = new TimerTask() {
    int loop = 0;
    public void run() {
        if (loading) {
            loop++;
            if (loop == 1) {
...
voidrunRotateKeys()
run Rotate Keys
Timer timer = new Timer();
timer.schedule(new TimerTask() {
    @Override
    public void run() {
        System.out.println("Rotating keys...");
}, 2 * 60 * 1000, 2 * 60 * 1000);