Java Timer Usage getTimer(String id)

Here you can find the source of getTimer(String id)

Description

get Timer

License

Open Source License

Declaration

public static Timer getTimer(String id) 

Method Source Code


//package com.java2s;
/* // ww w  . ja va 2  s .c o  m
 * Copyright 2012 Devoteam http://www.devoteam.com
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * 
 * This file is part of Multi-Protocol Test Suite (MTS).
 * 
 * Multi-Protocol Test Suite (MTS) is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, either version 3 of the
 * License.
 * 
 * Multi-Protocol Test Suite (MTS) is distributed in the hope that it will
 * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Multi-Protocol Test Suite (MTS).
 * If not, see <http://www.gnu.org/licenses/>.
 * 
 */

import java.util.HashMap;
import java.util.Timer;

public class Main {
    private static HashMap<String, Timer> timerById = new HashMap<String, Timer>();

    public static Timer getTimer(String id) {
        Timer timer = timerById.get(id);

        if (null == timer) {
            timer = new Timer(true);
            timerById.put(id, timer);
        }

        return timer;
    }
}

Related

  1. delayedExit(final int status, final long delay)
  2. exitSystemAfterTimeout(final long delay)
  3. getMinIdleTimer()
  4. getQuickSearchTimer()
  5. getSlowTimer()
  6. mayNewTasksBeScheduled(Timer timer)
  7. printLoadToConsole(int milliOffset)
  8. runRotateKeys()
  9. schedule(final TimerTask task, final int delay, final int period)