Executor execute - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Executor execute method.

This code example shows how to use the following methods:execute
    super(vertx, orderedBgExec);
    this.bgExec = bgExec;
  } 
 
  public void execute(Runnable task) {
    bgExec.execute(wrapTask(task));
  } 
} 
8
CodeRank
This code example shows how to use the following methods:execute
     * {@inheritDoc} 
     * @see java.util.concurrent.Executor#execute(java.lang.Runnable) 
     */ 
    @Override 
    public void execute(Runnable command) {
        this.executor.execute(command);
    } 
 
    /** 
     * {@inheritDoc} 
     * @see java.util.concurrent.ExecutorService#shutdown() 
     */ 
    @Override 
    public void shutdown() { 
        // Don't shutdown managed executor 
    } 
 
    /** 
     * {@inheritDoc} 
     * @see java.util.concurrent.ExecutorService#shutdownNow() 
7
CodeRank
This code example shows how to use the following methods:
		try { 
			if (this.concurrentExecutor instanceof ExecutorService) {
				return ((ExecutorService) this.concurrentExecutor).submit(task);
			} 
			else { 
				FutureTask<T> future = new FutureTask<T>(task);
				this.concurrentExecutor.execute(future);
				return future;
			} 
		} 
		catch (RejectedExecutionException ex) {
			throw new TaskRejectedException(
					"Executor [" + this.concurrentExecutor + "] did not accept task: " + task, ex);
		} 
	} 
 
	@Override 
	public ListenableFuture<?> submitListenable(Runnable task) {
		try { 
			ListenableFutureTask<Object> future = new ListenableFutureTask<Object>(task, null);
7
CodeRank
This code example shows how to use the following methods:execute
     * {@inheritDoc} 
     * @see java.util.concurrent.Executor#execute(java.lang.Runnable) 
     */ 
    @Override 
    public void execute(Runnable command) {
        this.executor.execute(command);
    } 
 
    /** 
     * {@inheritDoc} 
     * @see java.util.concurrent.ExecutorService#shutdown() 
     */ 
    @Override 
    public void shutdown() { 
        // Don't shutdown managed executor 
    } 
 
    /** 
     * {@inheritDoc} 
     * @see java.util.concurrent.ExecutorService#shutdownNow() 
7
CodeRank
This code example shows how to use the following methods:execute
    this.workerExec = workerExec;
  } 
 
  @Override 
  public void executeAsync(Handler<Void> task) {
    workerExec.execute(wrapTask(null, task, true));
  } 
 
  @Override 
  public boolean isEventLoopContext() { 
    return false; 
  } 
 
  @Override 
  public boolean isMultiThreaded() { 
    return false; 
  } 
 
  @Override 
  protected void checkCorrectThread() { 
7
CodeRank
This code example shows how to use the following methods:execute
 
  @Override 
  public void execute(Runnable runnable)
  { 
    emitMetrics(); 
    base.execute(runnable);
  } 
 
  private void emitMetrics() 
  { 
    if (base instanceof ThreadPoolExecutor) {
      emitter.emit(metricBuilder.build("exec/backlog", ((ThreadPoolExecutor) base).getQueue().size()));
    } 
  } 
} 
7
CodeRank
This code example shows how to use the following methods:execute
	public boolean runInThread(Runnable runnable) {
		if (runnable == null) {
			return false; 
		} 
		try { 
			this.taskExecutor.execute(runnable);
			return true; 
		} 
		catch (RejectedExecutionException ex) {
			logger.error("Task has been rejected by TaskExecutor", ex);
			return false; 
		} 
	} 
 
	@Override 
	public int blockForAvailableThreads() { 
		// The present implementation always returns 1, making Quartz 
		// always schedule any tasks that it feels like scheduling. 
		// This could be made smarter for specific TaskExecutors, 
		// for example calling {@code getMaximumPoolSize() - getActiveCount()} 
7
CodeRank
This code example shows how to use the following methods:execute
 
        RunIdSequence runIdSequence = new RunIdSequence();
        ClassLoader classLoader = getClass().getClassLoader();
 
        ActorRef<TestFileFinderListener> suiteRunner = actorThread.bindActor(TestFileFinderListener.class,
                new SuiteRunner( 
                        new DriverFactory(suiteListener, actorThread, outputCapturer, driverFinder, runIdSequence, classLoader),
                        suiteListener,
                        actorThread,
                        testExecutor,
                        new PrintStream(new NullOutputStream())
                )); 
 
        suiteListener.onSuiteStarted();
        testExecutor.execute(new TestFileFinderRunner(new StubTestFileFinder(testClasses), suiteRunner));
        actors.processEventsUntilIdle();
    } 
 
 
    // setters for changing the defaults 
6
CodeRank
This code example shows how to use the following methods:execute
                        }; 
                WildFlySecurityManager.doChecked(privilegedAction, accessControlContext);
            } 
        }; 
        try { 
            executor.execute(task);
        } catch (RejectedExecutionException e) {
            task.run();
        } finally { 
            context.asynchronous();
        } 
    } 
 
    @Override 
    public void stop(final StopContext context) {
        final ExecutorService executor = executorInjector.getValue();
        final AccessControlContext accessControlContext =
                AccessController.doPrivileged(GetAccessControlContextAction.getInstance());
 
        final Runnable task = new Runnable() {
7
CodeRank
This code example shows how to use the following methods:
        this.executor = executor;
    } 
 
 
    public FutureTask<Void> future() {
        future = new FutureTask<Void>( newTask(), null );
        return future;
    } 
 
    public SafeAsyncTask<ResultT> executor( Executor executor ) {
        this.executor = executor;
        return this;
    } 
 
    public Executor executor() {
        return executor;
    } 
 
    public SafeAsyncTask<ResultT> handler( Handler handler ) {
        this.handler = handler;

6
CodeRank

Related Executor execute Questions & Answers:

execute Method Overview
Executes the given command at some time in the future.
See Code Examples for other Java 8 Executor Methods: