Example usage for com.google.common.util.concurrent ListeningScheduledExecutorService shutdown

List of usage examples for com.google.common.util.concurrent ListeningScheduledExecutorService shutdown

Introduction

In this page you can find the example usage for com.google.common.util.concurrent ListeningScheduledExecutorService shutdown.

Prototype

void shutdown();

Source Link

Document

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.

Usage

From source file:org.apache.bookkeeper.stream.common.Scheduler.java

/**
 * Shutdown the scheduler//w w  w . j  a  v a  2s. c o m
 */
public void shutdown() {
    for (ListeningScheduledExecutorService executor : executors) {
        executor.shutdown();
    }
}

From source file:com.github.rinde.rinsim.core.model.time.RealtimeModel.java

void shutdownExecutor() {
    LOGGER.trace("Shutting down executor..");
    final ListeningScheduledExecutorService ex = realtimeState.executor;
    if (ex != null) {
        ex.shutdown();

        // in case the future could not be cancelled before, do it now
        final ListenableScheduledFuture<?> fut = realtimeState.schedulerFuture;
        if (fut != null && !fut.isDone()) {
            realtimeState.cancelTask();/*w  w  w.j  a v a 2  s  .  com*/
        }

        try {
            ex.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
        } catch (final InterruptedException e) {
            throw new IllegalStateException(e);
        }
        LOGGER.trace("Executor shutdown.");
    }
    verifyNotNull(affinityLock).release();
}