Java Timer Usage stop(final TimerTask task)

Here you can find the source of stop(final TimerTask task)

Description

stop

License

Open Source License

Declaration

public synchronized static void stop(final TimerTask task) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007, 2013 compeople AG and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/* w  ww  .j  a va2s.  co m*/
 *    compeople AG - initial API and implementation
 *******************************************************************************/

import java.util.HashSet;
import java.util.Set;

import java.util.TimerTask;

public class Main {
    private static Set<TimerTask> tasks = new HashSet<TimerTask>();

    public synchronized static void stop(final TimerTask task) {
        // stop a specific task
        task.cancel();
        tasks.remove(task);
    }
}

Related

  1. printLoadToConsole(int milliOffset)
  2. runRotateKeys()
  3. schedule(final TimerTask task, final int delay, final int period)
  4. schedule(TimerTask task, long delay, long period, String name)
  5. startTimerWithDelayInMillis(TimerTask task, long millisToDelay, long intervalInMillis)
  6. stopPrintStackTraces()
  7. timerTask(Runnable runnable)