Here you can find the source of stop(final TimerTask task)
public synchronized static void stop(final TimerTask task)
//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); } }