Takes a {@code Runnable} and immediately executes it if this is called on the designated GUI thread, otherwise
schedules it for later invocation.
@param runnable {@code Runnable} to execute on the GUI thread
188341
protected void runOnGUIThreadIfExistsOtherwiseRunDirect(Runnable runnable) {
        if(getTextGUI() != null && getTextGUI().getGUIThread() != null) {
            getTextGUI().getGUIThread().invokeLater(runnable);
        }
        else {
            runnable.run();
        }
    }
532896
private void startNewReconstituteThread(Runnable runnable) throws InterruptedException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "startNewReconstituteThread");

        if (_reconstituteThreadpool == null)
        {
            createReconstituteThreadPool();
        }

        _reconstituteThreadpool.execute(runnable);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "startNewReconstituteThread");
    }
954882
@Override
  public void execute(TxScope scope, Runnable runnable) {
    methodCalls.add(MethodCall.of("bulkUpdate").with("scope", scope, "runnable", runnable));
    delegate.execute(scope, runnable);
  }
1012020
public function setRunnable( $_runnable ) {
		if( self::runnableOk( $_runnable ) ) {
			$this->runnable = $_runnable;
		}
		else {
			throw new Exception( $this->getError( Thread::FUNCTION_NOT_CALLABLE ), Thread::FUNCTION_NOT_CALLABLE );
		}
	}
479915
@Override
	public void addJvmMemberInitializer(Runnable runnable) {
		if (isInitializingJvmMembers) {
			throw new IllegalStateException("Cannot enqueue runnables during JvmMemberInitialization");
		}
		if (this.jvmMemberInitializers == null) {
			this.jvmMemberInitializers = new LinkedHashSet<Runnable>();
			this.hasJvmMemberInitializers = true;
			for (EObject obj : getContents()) {
				if (obj instanceof JvmDeclaredTypeImplCustom) {
					JvmDeclaredTypeImplCustom type = (JvmDeclaredTypeImplCustom) obj;
					markPendingInitialization(type);
				}
			}
		}
		this.jvmMemberInitializers.add(runnable);
	}
1107271
@Override
  public void execute(Runnable runnable) {
    if (runnable == null) {
      throw new NullPointerException("runnable parameter is null");
    }

    if (!mWorkQueue.offer(runnable)) {
      throw new RejectedExecutionException(
          mName + " queue is full, size=" + mWorkQueue.size());
    }

    final int queueSize = mWorkQueue.size();
    final int maxSize = mMaxQueueSize.get();
    if ((queueSize > maxSize) && mMaxQueueSize.compareAndSet(maxSize, queueSize)) {
      FLog.v(TAG, "%s: max pending work in queue = %d", mName, queueSize);
    } // else, there was a race and another thread updated and logged the max queue size

    startWorkerIfNeeded();
  }
1164957
private static void executeListener(Runnable runnable, Executor executor) {
    try {
      executor.execute(runnable);
    } catch (RuntimeException e) {
      // Log it and keep going -- bad runnable and/or executor. Don't punish the other runnables if
      // we're given a bad one. We only catch RuntimeException because we want Errors to propagate
      // up.
      log.fatal(
          "RuntimeException while executing runnable " + runnable + " with executor " + executor,
          e);
    }
  }
762916
static void execute(Tenant tenant, Runnable runnable) {
        startTenantFlow();
        try {
            getThreadLocalInstance().setTenant(tenant);
            runnable.run();
        } finally {
            endTenantFlow();
        }
    }
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;
	}
297563
public C run(Runnable runnable) throws SniffyAssertionError {
        checkOpened();
        try {
            runnable.run();
        } catch (Throwable e) {
            throw verifyAndAddToException(e);
        }

        verify();
        return self();
    }
600069
@Override
    public void run() {
        // Check for a pending exception.  A CancellationException could be set if a cancel() was driven while this Runnable
        // was being re-scheduled.
        if (this.m_pendingException != null) {
            return;
        }

        // NOTE: Already running in Default Executor thread.
        try {
            this.m_runnable.run();
        } catch (Exception e) {
            this.m_pendingException = new ExecutionException(e);
            this.m_coordinationLatch.countDown();
            return;
        }

        try {
            long scheduleTime = this.m_periodInterval;
            if (!this.m_scheduledWithDelay) {
                this.m_myNextExecutionTime = this.m_myNextExecutionTime + this.m_periodInterval;
                long currentTime = System.nanoTime();

                scheduleTime = (this.m_myNextExecutionTime > currentTime) ? (this.m_myNextExecutionTime - currentTime) : 0;
            }

            m_schedFuture = this.m_scheduledExecutor.schedule(this, scheduleTime, TimeUnit.NANOSECONDS);
        } catch (Exception e) {
            this.m_pendingException = e;
            this.m_coordinationLatch.countDown();
        }
    }
112454
private Runnable runStepAndResetIsRunning(Runnable runnable) {
        return () -> {
            try {
                runnable.run();
            } catch (Throwable t) {
                //we're in control of the runnable and it should catch it's own execeptions, but just in case it doesn't
                log.error("Exeception while running a step", t);
            } finally {
                isRunningAStep.getAndSet(false);
            }
        };
    }
77653
public final <T> T executeInTransaction(final Runnable<T> runnable) throws Exception {
        return executeInTransaction(runnable, true);
    }
35622
protected final void runOnUiThread(@NonNull Runnable runnable) {
        checkNotNull(runnable, "runnable");
        if (Looper.myLooper() == Looper.getMainLooper()) {
            runnable.run();
        } else {
            mPoster.post(runnable);
        }
    }
1022685
@Weight(Weight.Unit.NORMAL)
  public static Runnable defer(@Nonnull final Runnable runnable) {
    assertNotNull(runnable);
    defer(new Deferred() {
      private static final long serialVersionUID = 2061489024868070733L;
      private final Runnable value = runnable;

      @Override
      public void executeDeferred() throws Exception {
        this.value.run();
      }
    });
    return runnable;
  }
371900
void enqueue(Runnable runnable, boolean flush) {
    queue.add(new RunnableCommand(runnable));
    if (flush) {
      scheduleFlush();
    }
  }
1238387
protected void scheduleRunAsync(Runnable runnable, long delay, TimeUnit unit) {
		componentMainThreadExecutor.schedule(runnable, delay, unit);
	}