List of usage examples for com.google.common.util.concurrent ListeningScheduledExecutorService awaitTermination
boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException;
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();/*from w ww. j a v a 2s . c o m*/ // in case the future could not be cancelled before, do it now final ListenableScheduledFuture<?> fut = realtimeState.schedulerFuture; if (fut != null && !fut.isDone()) { realtimeState.cancelTask(); } try { ex.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); } catch (final InterruptedException e) { throw new IllegalStateException(e); } LOGGER.trace("Executor shutdown."); } verifyNotNull(affinityLock).release(); }