Creates an interval that executes the supplied runnable on the specified RunQueue when it
expires.
483766
public static Interval create (RunQueue runQueue, final Runnable onExpired)
    {
        // we could probably avoid all the wacky machinations internal to Interval that do the
        // runbuddy reposting and whatever and just create a non-runqueue interval that posts the
        // supplied runnable to the runqueue when it expires, but we'll just punt on that for now
        return new Interval(runQueue) {
            @Override public void expired () {
                onExpired.run();
            }
            @Override public String toString () {
                return onExpired.toString();
            }
        };
    }
1218586
private static Runnable asRunnable(final ClientTransport.PingCallback callback,
                                     final long roundTripTimeNanos) {
    return new Runnable() {
      @Override
      public void run() {
        callback.onSuccess(roundTripTimeNanos);
      }
    };

  }
85148
public static ScheduledFuture<?> runWithScheduleWithFixedDelay(
            long initialDelayMillis, long delayMillis, Runnable runnable) {
        return runWithScheduleWithFixedDelay(initialDelayMillis, delayMillis,
                "runWithScheduleWithFixedDelay", runnable);
    }
371900
void enqueue(Runnable runnable, boolean flush) {
    queue.add(new RunnableCommand(runnable));
    if (flush) {
      scheduleFlush();
    }
  }
1038423
public ScheduledFuture<?> runOnExpiration(Runnable task, ScheduledExecutorService scheduler) {
    checkNotNull(task, "task");
    checkNotNull(scheduler, "scheduler");
    return scheduler.schedule(task, deadlineNanos - ticker.read(), TimeUnit.NANOSECONDS);
  }
430891
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value) {
        return new ForkJoinTask.AdaptedRunnable<T>(runnable, value);
    }
812148
public static Runnable excAsync(final Runnable runnable, boolean isDeamon) {
		Thread thread = new Thread() {
			@Override
			public void run() {
				runnable.run();
			}
		};
		thread.setDaemon(isDeamon);
		thread.start();

		return runnable;
	}
1112051
public static void scheduleAtFixedRate(ScheduledExecutorService exec, Duration rate, Runnable runnable)
  {
    scheduleAtFixedRate(exec, rate, rate, runnable);
  }
699843
public static ScheduledFuture scheduleWithFixedDelay(Runnable runnable, long delayInMilli) {
        /* 我们默认设定一个runnable生命周期与一个msgId一一对应 */
        Runnable proxy = wrapRunnable(runnable, null);
        return newSingleThreadScheduler().scheduleWithFixedDelay(proxy, 0, delayInMilli, TimeUnit.MILLISECONDS);
    }
1090362
public <T extends Runnable> T executeAsyncTimed(T runnable, long inMs) {
		final Runnable theRunnable = runnable;

		// This implementation is not really suitable for now as the timer uses its own thread
		// The TaskQueue itself should be able in the future to handle this without using a new thread
		Timer timer = new Timer();
		timer.schedule(new TimerTask() {

			@Override
			public void run() {
				TaskQueue.this.executeAsync(theRunnable);
			}
		}, inMs);

		return runnable;
	}
273607
@SuppressWarnings("static-method")
	protected Runnable createTask(Runnable runnable) {
		if (runnable instanceof JanusRunnable) {
			return runnable;
		}
		return new JanusRunnable(runnable);
	}
1086929
def scheduledTimes(self, runnable):
        
        events = self.store.query(
            TimedEvent, TimedEvent.runnable == runnable)
        return (event.time for event in events if not event.running)
1328949
public void runQueue() {
    synchronized(sync) {
      while(!queue.isEmpty()) {
        Runnable r = queue.poll();
        if(r != null) {
          try {
            r.run();
          }
          catch(Exception e) {
            // Alternatively, we could allow the specification of exception
            // handlers for each runnable in the API. For now we'll just log.
            // TODO: handle exceptions here better!
            LoggingUtil.exception(e);
          }
        }
        else {
          LoggingUtil.warning("Tried to run a 'null' Object.");
        }
      }
    }
  }
392069
public ServerListenerBuilder addStoppingCallback(Runnable runnable) {
        requireNonNull(runnable, "runnable");
        serverStoppingCallbacks.add(unused -> runnable.run());
        return this;
    }
1179490
public Thread createThread(Runnable runnable) {
        Thread thread = new Thread(getThreadGroup(), runnable, nextThreadName());
        thread.setPriority(getThreadPriority());
        thread.setDaemon(isDaemon());
        return thread;
    }
231698
@Nonnull
  public static TimeValue runMeasured (@Nonnull final Runnable aRunnable)
  {
    final StopWatch aSW = createdStarted ();
    aRunnable.run ();
    final long nNanos = aSW.stopAndGetNanos ();
    return new TimeValue (TimeUnit.NANOSECONDS, nNanos);
  }
758796
public static void scheduleAtFixedRate(
      final ScheduledExecutorService exec,
      final Duration initialDelay,
      final Duration period,
      final Runnable runnable
  )
  {
    scheduleAtFixedRate(exec, initialDelay, period, new Callable<Signal>()
    {
      @Override
      public Signal call()
      {
        runnable.run();
        return Signal.REPEAT;
      }
    });
  }