Times the {@link Runnable#run()} method of the given {@link Runnable}.

@param runnable the {@link Runnable} object to run and time.
@return the amount of time in milliseconds that it took to run the given {@link Runnable}.
@see java.lang.Runnable
767428
public static Optional<Long> timedRun(Runnable runnable) {
    long t0 = System.currentTimeMillis();
    runnable.run();
    return Optional.of(System.currentTimeMillis() - t0);
  }
296247
public static void step(final ThrowableContextRunnableVoid<StepContext> runnable) {
        step(step -> {
            runnable.run(step);
            return null;
        });
    }
595245
public static void asyncExecute(Runnable runnable) {
		if (runnable != null) {
			try {
				Para.getExecutorService().execute(runnable);
			} catch (RejectedExecutionException ex) {
				logger.warn(ex.getMessage());
				try {
					runnable.run();
				} catch (Exception e) {
					logger.error(null, e);
				}
			}
		}
	}
1007834
public static void runIntoJITSync(final JRebirthRunnable runnable, final long... timeout) {
        final SyncRunnable sync = new SyncRunnable(runnable);

        if (JRebirth.isJIT()) {
            // We are into a JIT so just run it synchronously
            sync.run();
            // Be careful in this case no timeout protection is achieved
        } else {
            // The runnable will be run into the JIT during the next round according to existing runnable priorities
            JRebirthThread.getThread().runLater(sync);
            // Wait the end of the runnable execution
            sync.waitEnd(timeout);
        }
    }
515506
public static Thread go(Runnable runnable, String threadName) {
        Thread thread = daemonThreadFrom(runnable);
        thread.setName(threadName);
        thread.start();
        return thread;
    }
1254406
public static ScheduledFuture<?> runWithScheduleWithFixedDelayOnStartTime(
            ZonedDateTime startDateTime, long delayMillis, Runnable runnable) {
        return runWithScheduleWithFixedDelay(
                calInitialDelayMillis(startDateTime), delayMillis,
                "runWithScheduleWithFixedDelayOnStartTime", 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)
275755
public void scheduleRecurring(Runnable runnable, Date firstTime, long period)
   {
	timer.scheduleAtFixedRate(toTimerTask(runnable), firstTime, period);
	
   }
451060
public void run(ExceptionalRunnable runnable) throws Exception {
		initStartTotal();
		long startInvokation = System.currentTimeMillis();
		runnable.run();
		invoked(System.currentTimeMillis() - startInvokation);
	}
98056
@SuppressWarnings("unchecked")
	public static boolean isRunnable(Class cl, String methodName, String[] filters) {
		try {
			Method m = cl.getMethod(methodName);
			return isRunnable(m, filters);
		}
		catch (NoSuchMethodException | SecurityException e) {
			return true;
		}
	}
85148
public static ScheduledFuture<?> runWithScheduleWithFixedDelay(
            long initialDelayMillis, long delayMillis, Runnable runnable) {
        return runWithScheduleWithFixedDelay(initialDelayMillis, delayMillis,
                "runWithScheduleWithFixedDelay", runnable);
    }
300890
protected void delayed(final Runnable runnable, long millis) {
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                try {
                    myExec.execute(runnable);
                } catch (Throwable t) {
                    log(t);
                }
            }
        }, millis);
    }
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);
  }
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;
	}
227710
public static void execute(Runnable runnable) {
		try {
			executor.execute(runnable);
		} catch (Exception e) {
			throw new UtilException(e, "Exception when running task!");
		}
	}
1238387
protected void scheduleRunAsync(Runnable runnable, long delay, TimeUnit unit) {
		componentMainThreadExecutor.schedule(runnable, delay, unit);
	}
706076
@Override
    public Thread newThread(final Runnable runnable) {
        Runnable wrapped = new Runnable() {
            @Override
            public void run() {
                try {
                    // As the runnable is wrapped in another runnable object, we call the run method directly.
                    runnable.run();     //NOSONAR
                } catch (Exception e) {  //NOSONAR
                    // Catching exception is acceptable here as the wrapped runnable can throw almost anything.
                    log.error("Error while executing " + Thread.currentThread().getName(), e);
                }
            }
        };
        Thread thread = factory.newThread(wrapped);
        thread.setName(prefix + "-" + thread.getName());
        return thread;
    }