Java Timer Usage timerTask(Runnable runnable)

Here you can find the source of timerTask(Runnable runnable)

Description

Wraps Runnable to TimerTask

License

Open Source License

Parameter

Parameter Description
runnable Runnable

Return

TimerTask

Declaration

public static TimerTask timerTask(Runnable runnable) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.TimerTask;

public class Main {
    /**/*w  ww.ja  v  a2s .c  om*/
     * Wraps Runnable to TimerTask
     *
     * @param runnable Runnable
     * @return TimerTask
     */
    public static TimerTask timerTask(Runnable runnable) {
        return new TimerTask() {
            @Override
            public void run() {
                runnable.run();
            }
        };
    }
}

Related

  1. schedule(final TimerTask task, final int delay, final int period)
  2. schedule(TimerTask task, long delay, long period, String name)
  3. startTimerWithDelayInMillis(TimerTask task, long millisToDelay, long intervalInMillis)
  4. stop(final TimerTask task)
  5. stopPrintStackTraces()