implement RunnableFuture.
430891
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value) {
        return new ForkJoinTask.AdaptedRunnable<T>(runnable, value);
    }
818670
public static CompletableFuture<Void> runAsync(Runnable runnable,
            Executor executor) {
        return runAsync(runnable,
                handleExceptionally("runAsync", runnable, executor), executor);
    }
593129
def run(self) -> None:
        """"""
        while self._running:
            try:
                future, function = self._tx.get(timeout=0.1)
            except Empty:
                continue

            try:
                LOG.debug("executing %s", function)
                result = function()
                LOG.debug("returning %s", result)
                self._loop.call_soon_threadsafe(future.set_result, result)
            except BaseException as e:
                LOG.exception("returning exception %s", e)
                self._loop.call_soon_threadsafe(future.set_exception, e)
1073112
function Runnable(title, fn) {
  this.title = title;
  this.fn = fn;
  this.body = (fn || '').toString();
  this.async = fn && fn.length;
  this.sync = !this.async;
  this._timeout = 2000;
  this._slow = 75;
  this._enableTimeouts = true;
  this.timedOut = false;
  this._retries = -1;
  this._currentRetry = 0;
  this.pending = false;
}
845576
public void run()
    {
        try
        {
            if (!thread.compareAndSet(null, Thread.currentThread()))
            {
                return;
            }

            final IdleStrategy idleStrategy = this.idleStrategy;
            final Agent agent = this.agent;
            try
            {
                agent.onStart();
            }
            catch (final Throwable throwable)
            {
                errorHandler.onError(throwable);
                isRunning = false;
            }

            while (isRunning)
            {
                if (doDutyCycle(idleStrategy, agent))
                {
                    break;
                }
            }

            try
            {
                agent.onClose();
            }
            catch (final Throwable throwable)
            {
                errorHandler.onError(throwable);
            }
        }
        finally
        {
            isClosed = true;
        }
    }
191434
public void execute(Runnable command) {
        if (!(command instanceof ClusteredFutureTask)) {
            command = new ClusteredFutureTask<Object>(command, null);
        }
        command.run();
    }
186796
def run_fn_atomically(self, request):
        """"""
        fn = serializer.loads_fn(request[Msgs.info])
        args, kwargs = request[Msgs.args], request[Msgs.kwargs]
        with self.mutate_safely():
            self.reply(fn(self.state, *args, **kwargs))
960104
public void run(Runnable runnable, Executor executor)
    {
        if (this.goForward())
        {
            for (int i = this.from; i <= this.to; i += this.step)
            {
                executor.execute(runnable);
            }
        }
        else
        {
            for (int i = this.from; i >= this.to; i += this.step)
            {
                executor.execute(runnable);
            }
        }
    }
214622
public void executeWithDelay() {
        long now = Clock.currentTimeMillis();
        if (delay + now > hardLimit) {
            scheduleNewExecution(now);
        } else if (!tryPostponeExecution()) {
            scheduleNewExecution(now);
        }
    }
6295
@Override
    public synchronized void run(){
        Date now = new Date();
        if ( !cache.isEmpty() &&
                ((cache.size() > cacheSize - 1) || (now.getTime() - lastCacheAccess.getTime() > cacheMillis))) {
            try {
                flush();
            } catch (RepositoryException e) {
                log.error(e.getLocalizedMessage());
                throw new RuntimeException(e);
            } catch (MalformedQueryException e) {
                log.error(e.getLocalizedMessage());
                throw new RuntimeException(e);
            } catch (UpdateExecutionException e) {
                log.error(e.getLocalizedMessage());
                throw new RuntimeException(e);
            } catch (IOException e) {
                log.error(e.getLocalizedMessage());
                throw new RuntimeException(e);
            }
        }
    }
985215
def run_thread(self):
        """"""
        self._run_thread = True
        self._thread.setDaemon(True)
        self._thread.start()
277519
@Override
  public void run() {
    try {
      barrier.await();
      rv = callable.call();
    } catch (Throwable t) {
      throwable = t;
    }
    latch.countDown();
  }
165845
public synchronized void execute(Runnable command) {
        if (active.get()) {
            stop();
            this.command = command;
            start();
        } else {
            this.command = command;
        }
    }
1234942
@Override
	public void run() {

		while (!stopProcessing.get()) {

			try {
				JawrWatchEvent evt = watchEvents.take();
				AtomicBoolean processingBundle = bundlesHandler.isProcessingBundle();
				synchronized (processingBundle) {

					// Wait until processing ends
					while (processingBundle.get() && !stopProcessing.get()) {
						try {
							processingBundle.wait();
						} catch (InterruptedException e) {
							LOGGER.debug("Thread interrupted");
						}
					}
				}
				if (evt != null && !stopProcessing.get()) {
					process(evt);
				}
			} catch (InterruptedException e) {
				LOGGER.debug("Thread interrupted");
			}
		}
		
		this.bundlesHandler = null;
		this.watcher = null;
	}
1218586
private static Runnable asRunnable(final ClientTransport.PingCallback callback,
                                     final long roundTripTimeNanos) {
    return new Runnable() {
      @Override
      public void run() {
        callback.onSuccess(roundTripTimeNanos);
      }
    };

  }
1000477
void runTask(PolicyTaskFutureImpl<?> future) {
        running.add(future); // intentionally done before checking state to avoid missing cancels on shutdownNow
        int runCount = runningCount.incrementAndGet();
        try {
            Callback callback = cbLateStart.get();
            if (callback != null) {
                long delay = future.nsQueueEnd - future.nsAcceptBegin;
                if (delay > callback.threshold
                    && cbLateStart.compareAndSet(callback, null)) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        Tr.debug(this, tc, "callback: late start " + delay + "ns > " + callback.threshold + "ns", callback.runnable);
                    globalExecutor.submit(callback.runnable);
                }
            }

            callback = cbConcurrency.get();
            if (callback != null
                && runCount > callback.threshold
                && cbConcurrency.compareAndSet(callback, null)) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(this, tc, "callback: concurrency > " + callback.threshold, callback.runnable);
                globalExecutor.submit(callback.runnable);
            }

            if (state.get().canStartTask) {
                future.run();
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(this, tc, "Cancel task due to policy executor state " + state);
                future.nsRunEnd = System.nanoTime();
                future.cancel(false);
                if (future.callback != null)
                    future.callback.onEnd(future.task, future, null, true, 0, null); // aborted, queued task will never run
            }
        } catch (Error x) {
            // auto FFDC
        } catch (RuntimeException x) {
            // auto FFDC
        } finally {
            runningCount.decrementAndGet();
            running.remove(future);
        }
    }
347305
def done(self):
        """"""
        # Flush the current future in the local buffer (potential deadlock
        # otherwise)
        try:
            scoop._control.execQueue.remove(self)
            scoop._control.execQueue.socket.sendFuture(self)
        except ValueError as e:
            # Future was not in the local queue, everything is fine
            pass
        # Process buffers
        scoop._control.execQueue.updateQueue()
        return self._ended()