Example usage for java.util.concurrent ThreadPoolExecutor isShutdown

List of usage examples for java.util.concurrent ThreadPoolExecutor isShutdown

Introduction

In this page you can find the example usage for java.util.concurrent ThreadPoolExecutor isShutdown.

Prototype

public boolean isShutdown() 

Source Link

Usage

From source file:org.apache.hadoop.hbase.index.parallel.ThreadPoolManager.java

static synchronized ThreadPoolExecutor getExecutor(ThreadPoolBuilder builder, Map<String, Object> poolCache) {
    ThreadPoolExecutor pool = (ThreadPoolExecutor) poolCache.get(builder.getName());
    if (pool == null || pool.isTerminating() || pool.isShutdown()) {
        pool = getDefaultExecutor(builder);
        LOG.info("Creating new pool for " + builder.getName());
        poolCache.put(builder.getName(), pool);
    }/* w  w  w.  ja  va  2  s  .co m*/
    ((ShutdownOnUnusedThreadPoolExecutor) pool).addReference();

    return pool;
}

From source file:org.springframework.integration.util.CallerBlocksPolicy.java

@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
    if (!executor.isShutdown()) {
        try {//from ww w .j  a v  a 2 s . c  o  m
            BlockingQueue<Runnable> queue = executor.getQueue();
            if (logger.isDebugEnabled()) {
                logger.debug("Attempting to queue task execution for " + this.maxWait + " milliseconds");
            }
            if (!queue.offer(r, this.maxWait, TimeUnit.MILLISECONDS)) {
                throw new RejectedExecutionException("Max wait time expired to queue task");
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Task execution queued");
            }
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RejectedExecutionException("Interrupted", e);
        }
    } else {
        throw new RejectedExecutionException("Executor has been shut down");
    }
}