Here you can find the source of schedule(final TimerTask task, final int delay, final int period)
public synchronized static void schedule(final TimerTask task, final int delay, final int period)
//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:/*from w w w. jav a2s . c om*/ * compeople AG - initial API and implementation *******************************************************************************/ import java.util.HashSet; import java.util.Set; import java.util.Timer; import java.util.TimerTask; public class Main { private final static Timer TIMER = new Timer(); private static Set<TimerTask> tasks = new HashSet<TimerTask>(); public synchronized static void schedule(final TimerTask task, final int delay, final int period) { if (tasks.contains(task)) { return; } // the actual task of work TIMER.schedule(task, delay, period); tasks.add(task); } }