Java 8 Executor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Executor class.

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, isShutdown, isTerminated, shutdown
        assertEquals("Should use same thread", name1, name2);
    } 
 
    public void testSynchronousExecutorServiceShutdown() throws Exception {
        ExecutorService service = new SynchronousExecutorService();
        service.execute(new Runnable() {
            public void run() { 
                invoked = true;
            } 
        }); 
        service.shutdown();
 
        assertTrue(service.isShutdown());
        assertTrue(service.isTerminated());
    } 
} 
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
	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
     * {@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, awaitTermination, shutdown
        } 
        return fc;
    } 
 
    public void close() throws Exception {
        es.execute(new Runnable() {
            @Override 
            public void run() { 
                try { 
                    for (Map.Entry<String, FileChannel> e : m_outputFiles.entrySet()) {
                        FileChannel fc = e.getValue();
                        String message = "Output " + fc.size() + " bytes worth of duplicate row data for table " + e.getKey();
                        SNAP_LOG.warn(message);
                        fc.force(true);
                        fc.close();
                    } 
                    m_outputFiles.clear();
                } catch (Exception e) {
                    VoltDB.crashLocalVoltDB("Error syncing and closing duplicate files during snapshot restore", true, e);
                } 

6
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
	 * @see java.util.concurrent.Executor#execute(Runnable) 
	 */ 
	@Override 
	public void execute(Runnable task) {
		try { 
			this.concurrentExecutor.execute(task);
		} 
		catch (RejectedExecutionException ex) {
			throw new TaskRejectedException(
					"Executor [" + this.concurrentExecutor + "] did not accept task: " + task, ex);
		} 
	} 
 
	@Override 
	public void execute(Runnable task, long startTimeout) {
		execute(task);
	} 
 
	@Override 
	public Future<?> submit(Runnable task) {
6
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, awaitTermination, shutdown, scheduleWithFixedDelay
    long getDeletesSinceLastChecked() { 
        return deletesSinceLastChecked.getAndSet(0);
    } 
 
    void shutdown() { 
        scheduler.shutdown();
        try { 
            scheduler.awaitTermination(60, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block 
            e.printStackTrace();
        } 
 
        try { 
            // block until all outstanding txns return 
            client.drain();
            // close down the client connections 
            client.close();
        } 
        catch (IOException | InterruptedException e) {

7
CodeRank

Related Java 8 Executor Questions & Answers:

See Code Examples for Java 8 Executor Methods: