java.util.TimerTask.run()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(181)

本文整理了Java中java.util.TimerTask.run()方法的一些代码示例,展示了TimerTask.run()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimerTask.run()方法的具体详情如下:
包路径:java.util.TimerTask
类名称:TimerTask
方法名:run

TimerTask.run介绍

[英]The task to run should be specified in the implementation of the run()method.
[中]应该在run()方法的实现中指定要运行的任务。

代码示例

代码示例来源: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: jphp-group/jphp

@Signature
public void run() {
  getWrappedObject().run();
}

代码示例来源:origin: robovm/robovm

task.run();
  taskCompletedNormally = true;
} finally {

代码示例来源: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: 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, long)
 */
public void schedule(TimerTask task, long delay) {
  if (timerThreadRunning) {
    timer.schedule(task, delay);
  } else {
    task.run();
  }
}

代码示例来源: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, long)
 */
public void schedule(TimerTask task, Date firstTime, long period) {
  if (timerThreadRunning) {
    timer.schedule(task, firstTime, period);
  } else {
    task.run();
  }
}

代码示例来源: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, long, long)
 */
public void schedule(TimerTask task, long delay, long period) {
  if (timerThreadRunning) {
    timer.schedule(task, delay, period);
  } else {
    task.run();
  }
}

代码示例来源: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: 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, long, long)
 */
public void scheduleAtFixedRate(TimerTask task, long delay, long period) {
  if (timerThreadRunning) {
    timer.scheduleAtFixedRate(task, delay, period);
  } else {
    task.run();
  }
}

代码示例来源:origin: naver/ngrinder

reportTimerTask.run();
reportTimerTask.run();

代码示例来源:origin: com.custardsource.parfait/parfait-core

@VisibleForTesting
static void runAllTasks() {
  for (TimerTask task : SCHEDULED_TASKS) {
    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: de.mhus.lib/mhu-lib-karaf

@Override
public void run(Object environment) {
  if (task instanceof ITimerTask)
    ((ITimerTask)task).run(environment);
  else
    task.run();
}

代码示例来源:origin: org.n52.amused/amused-util

/**
 * 
 * Executes the timer's task whether the timer is scheduled or not. The 
 * implementation first tries to cancel the timer, then executes the 
 * task directly (via TimerTask.run()).
 *
 */
public final void executeNow()
{
  cancel();
  _task.run();
}

代码示例来源:origin: performancecopilot/parfait

void runAllScheduledTasks() {
  for (TimerTask task : scheduledRates.keySet()) {
    task.run();
  }
}

代码示例来源:origin: de.mhus.lib/mhu-lib-core

@Override
public void doit() throws Exception {
  if (task instanceof ITimerTask && ((ITimerTask)task).isCanceled()) {
    cancel();
    return;
  }
    
  task.run();
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void handleEvent(Event event) {
    btnRefresh.setData("Pressing", "1");
    task.run();
    btnRefresh.setData("Pressing", null);
  }
});

代码示例来源:origin: de.mhus.lib/mhu-lib-core

protected void doit() throws Exception {
  if (task == null) {
    cancel();
    return;
  }
  TimerTask taskTask = task.get();
  if (taskTask == null || MTimerTask.getStatus(taskTask) == MTimerTask.CANCELLED ) {
    cancel();
    return;
  }
  
  taskTask.run();
}

代码示例来源:origin: joel-costigliola/assertj-swing

@Override
public void run() {
 if (isCanceled()) {
  cancel();
  return;
 }
 try {
  task.run();
 } catch (Throwable thrown) {
  handleException(thrown);
 }
}

代码示例来源:origin: apereo/java-cas-client

public void testRun() throws Exception {
  final ProxyGrantingTicketStorageTestImpl storage = new ProxyGrantingTicketStorageTestImpl();
  new Cas20ProxyReceivingTicketValidationFilter().setProxyGrantingTicketStorage(storage);
  final TimerTask timerTask = new CleanUpTimerTask(storage);
  timerTask.run();
  assertTrue(storage.cleanUpWasCalled());
}

相关文章