Tabnine Logo
TimerTask
Code IndexAdd Tabnine to your IDE (free)

How to use
TimerTask
in
java.util

Best Java code snippets using java.util.TimerTask (Showing top 20 results out of 3,735)

Refine searchRefine arrow

  • Timer
origin: TooTallNate/Java-WebSocket

/**
 * Cancel any running timer for the connection lost detection
 * @since 1.3.4
 */
private void cancelConnectionLostTimer() {
  if( connectionLostTimer != null ) {
    connectionLostTimer.cancel();
    connectionLostTimer = null;
  }
  if( connectionLostTimerTask != null ) {
    connectionLostTimerTask.cancel();
    connectionLostTimerTask = null;
  }
}
origin: apache/hbase

 /**
  * Trigger the timer immediately.
  * <p>
  * Exposed for testing.
  */
 public void trigger() {
  synchronized (timerTask) {
   if (this.complete) {
    LOG.warn("Timer already completed, not triggering.");
    return;
   }
   LOG.debug("Triggering timer immediately!");
   this.timer.cancel();
   this.timerTask.run();
  }
 }
}
origin: robovm/robovm

if (task.isScheduled()) {
  throw new IllegalStateException("TimerTask is scheduled already");
origin: apollographql/apollo-android

void schedule(final int taskId, final Runnable task, long delay) {
 TimerTask timerTask = new TimerTask() {
  @Override public void run() {
   try {
    task.run();
   } finally {
    cancelTask(taskId);
   }
  }
 };
 synchronized (this) {
  TimerTask previousTimerTask = tasks.put(taskId, timerTask);
  if (previousTimerTask != null) {
   previousTimerTask.cancel();
  }
  if (timer == null) {
   timer = new Timer("Subscription SmartTimer", true);
  }
  timer.schedule(timerTask, delay);
 }
}
origin: naver/ngrinder

reportTimerTask.run();
final Timer timer = new Timer(true);
timer.schedule(reportTimerTask, reportToConsoleInterval, reportToConsoleInterval);
    m_terminalLogger.info("This test will shut down after {} ms", duration);
    timer.schedule(shutdownTimerTask, duration);
  reportTimerTask.cancel();
  shutdownTimerTask.cancel();
reportTimerTask.run();
origin: org.eclipse.jetty/jetty-util

public void schedule ()
{  
  if (_running)
  {
    if (_timer!=null)
      _timer.cancel();
    if (_task!=null)
      _task.cancel();
    if (getScanInterval() > 0)
    {
      _timer = newTimer();
      _task = newTimerTask();
      _timer.schedule(_task, 1010L*getScanInterval(),1010L*getScanInterval());
    }
  }
}
/**
origin: k9mail/k-9

  private void raiseNotification() {
    if (timer != null) {
      synchronized (timer) {
        if (timerTask != null) {
          timerTask.cancel();
          timerTask = null;
        }
        timerTask = new TimerTask() {
          @Override
          public void run() {
            if (startTime != null) {
              Long endTime = SystemClock.elapsedRealtime();
              Timber.i("TracingWakeLock for tag %s / id %d: has been active for %d ms, timeout = %d ms",
                  tag, id, endTime - startTime, timeout);
            } else {
              Timber.i("TracingWakeLock for tag %s / id %d: still active, timeout = %d ms",
                  tag, id, timeout);
            }
          }
        };
        timer.schedule(timerTask, 1000, 1000);
      }
    }
  }
}
origin: stackoverflow.com

final TimerTask tt = new TimerTask() {
   @Override
   public void run() {
     if (count < 1000) {
       //increment rectangles y position
       //now repaint container so we can see changes in co-ordinates (unless you have a timer which repaints for you too)
     count++;
     } else {//counter is at 1000 stop the timer
       cancel();
     }
   }
 };
 new Timer().scheduleAtFixedRate(tt, 0, 10);//start in 0milis and call run every 10 milis
origin: net.sf.ehcache/ehcache

/**
 * If the runtime environment restricts thread creation, the task is run
 * inline for only one time. No further repeated execution happens for the
 * task
 * 
 * @see java.util.Timer#schedule(java.util.TimerTask, java.util.Date)
 */
public void schedule(TimerTask task, Date time) {
  if (timerThreadRunning) {
    timer.schedule(task, time);
  } else {
    task.run();
  }
}
origin: Demidong/ClockView

public void startCountDown(){
  timer= new Timer();
  TimerTask timerTask =new TimerTask() {
    @Override
    public void run() {
      handler.sendEmptyMessage(0);
    }
  };
  timer.schedule(timerTask,0,1000);
  timerTask.run();
}
public void finishCount(){
origin: apache/storm

public void shutdown() {
  if (cleanup != null) {
    cleanup.cancel();
    cleanup = null;
  }
}
origin: kingthy/TVRemoteIME

private void stopGetGuidTimer() {
  if (this.mGetGuidTimer instanceof Timer) {
    this.mGetGuidTimer.cancel();
    this.mGetGuidTimer.purge();
    this.mGetGuidTimer = null;
    XLLog.i(TAG, "stopGetGuidTimer");
  }
  if (this.mGetGuidTimerTask instanceof TimerTask) {
    this.mGetGuidTimerTask.cancel();
    this.mGetGuidTimerTask = null;
  }
}
origin: apache/activemq

public static synchronized void cancel(Runnable task) {
  TimerTask ticket = TIMER_TASKS.remove(task);
  if (ticket != null) {
    ticket.cancel();
    CLOCK_DAEMON.purge();//remove cancelled TimerTasks
  }
}
origin: senseidb/zoie

public synchronized void setOptimizeDuration(long optimizeDuration) {
 if (_optimizeDuration != optimizeDuration) {
  _currentOptimizationTimerTask.cancel();
  _optimizeTimer.purge();
  _currentOptimizationTimerTask = new OptimizeTimerTask();
  _optimizeTimer.scheduleAtFixedRate(_currentOptimizationTimerTask, _dateToStartOptimize,
   optimizeDuration);
  _optimizeDuration = optimizeDuration;
 }
}
origin: net.sf.ehcache/ehcache

/**
 * If the runtime environment restricts thread creation, the task is run
 * inline for only one time. No further repeated execution happens for the
 * task
 * 
 * @see java.util.Timer#scheduleAtFixedRate(java.util.TimerTask, java.util.Date, long)
 */
public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period) {
  if (timerThreadRunning) {
    timer.scheduleAtFixedRate(task, firstTime, period);
  } else {
    task.run();
  }
}
origin: jphp-group/jphp

@Signature
public void run() {
  getWrappedObject().run();
}
origin: robovm/robovm

    task.setScheduledTime(task.when);
  task.run();
  taskCompletedNormally = true;
} finally {
origin: cSploit/android

@Override
public void onReceive(Context context, Intent intent) {
  synchronized (getActivity()) {
    if (mTask != null) {
      mTask.cancel();
    }
    mTask = new TimerTask() {
      @Override
      public void run() {
        check();
      }
    };
    new Timer().schedule(mTask, CHECK_DELAY);
  }
}
origin: org.mortbay.jetty/jetty-util

public void schedule ()
{  
  if (_running)
  {
    if (_timer!=null)
      _timer.cancel();
    if (_task!=null)
      _task.cancel();
    if (getScanInterval() > 0)
    {
      _timer = newTimer();
      _task = newTimerTask();
      _timer.schedule(_task, 1000L*getScanInterval(),1000L*getScanInterval());
    }
  }
}
/**
origin: internetarchive/heritrix3

  checkpointTask.cancel();
this.timer.schedule(checkpointTask, periodMs, periodMs);
LOGGER.info("Installed Checkpoint TimerTask to checkpoint every " +
    periodMs + " milliseconds.");
java.utilTimerTask

Javadoc

The TimerTask class represents a task to run at a specified time. The task may be run once or repeatedly.

Most used methods

  • cancel
    Cancels this timer task. If the task has been scheduled for one-time execution and has not yet run,
  • run
    The action to be performed by this timer task.
  • isScheduled
  • scheduledExecutionTime
    Returns the scheduled execution time of the most recentactual execution of this task. (If this metho
  • setScheduledTime
  • <init>
    Creates a new timer task.

Popular in Java

  • Updating database using SQL prepared statement
  • scheduleAtFixedRate (ScheduledExecutorService)
  • scheduleAtFixedRate (Timer)
  • compareTo (BigDecimal)
  • Permission (java.security)
    Legacy security code; do not use.
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now