Package java.util.concurrent

Examples of java.util.concurrent.RejectedExecutionHandler


        min_threads, max_threads, keep_alive_time,
        TimeUnit.MILLISECONDS, queue);
    pool.setThreadFactory(factory);

    // default
    RejectedExecutionHandler handler = new ThreadPoolExecutor.CallerRunsPolicy();
    if (rejection_policy != null) {
      if (rejection_policy.equals("abort"))
        handler = new ThreadPoolExecutor.AbortPolicy();
      else if (rejection_policy.equals("discard"))
        handler = new ThreadPoolExecutor.DiscardPolicy();
View Full Code Here


        final ThreadFactory threadFactory = new PoolExecutorThreadFactory(node.threadGroup,
                node.getThreadPoolNamePrefix("cached"), classLoader);

        cachedExecutorService = new ThreadPoolExecutor(
                3, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS,
                new SynchronousQueue<Runnable>(), threadFactory, new RejectedExecutionHandler() {
            public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                if (logger.isFinestEnabled()) {
                    logger.finest( "Node is shutting down; discarding the task: " + r);
                }
            }
View Full Code Here

            poolSize = Runtime.getRuntime().availableProcessors();
        }
        internalExecutor = new ThreadPoolExecutor(2, 2, 0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>(),
                new PoolExecutorThreadFactory(threadGroup, name + ".internal-", classLoader),
                new RejectedExecutionHandler() {
                    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                        String message = "Internal executor rejected task: " + r + ", because client is shutting down...";
                        logger.finest(message);
                        throw new RejectedExecutionException(message);
                    }
                });
        executor = new ThreadPoolExecutor(poolSize, poolSize, 0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>(),
                new PoolExecutorThreadFactory(threadGroup, name + ".cached-", classLoader),
                new RejectedExecutionHandler() {
                    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                        String message = "Internal executor rejected task: " + r + ", because client is shutting down...";
                        logger.finest(message);
                        throw new RejectedExecutionException(message);
                    }
View Full Code Here

        long keepAliveTime =
            configManager.getDuration(EnvironmentParams.EVICTOR_KEEP_ALIVE);
        terminateMillis = configManager.getDuration
            (EnvironmentParams.EVICTOR_TERMINATE_TIMEOUT);

        RejectedExecutionHandler rejectHandler =
            new RejectEvictHandler(nThreadUnavailable);
       
        evictionPool =
            new ThreadPoolExecutor(corePoolSize,
                                   maxPoolSize,
View Full Code Here

     *
     * @param target the target executor
     * @return the new handoff policy implementation
     */
    public static RejectedExecutionHandler handoffPolicy(final Executor target) {
        return new RejectedExecutionHandler() {
            public void rejectedExecution(final Runnable r, final ThreadPoolExecutor executor) {
                target.execute(r);
            }
        };
    }
View Full Code Here

    }

    protected void doStart() throws Exception {
        shutdown.set(false);
        if (executor != null) {
            executor.setRejectedExecutionHandler(new RejectedExecutionHandler() {
                public void rejectedExecution(Runnable runnable, ThreadPoolExecutor executor) {
                    ProcessCall call = (ProcessCall)runnable;
                    call.exchange.setException(new RejectedExecutionException());
                    call.callback.done(false);
                }
View Full Code Here

        return answer;
    }
   
    @Override
    public ScheduledExecutorService newScheduledThreadPool(ThreadPoolProfile profile, ThreadFactory threadFactory) {
        RejectedExecutionHandler rejectedExecutionHandler = profile.getRejectedExecutionHandler();
        if (rejectedExecutionHandler == null) {
            rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
        }

        ScheduledThreadPoolExecutor answer = new ScheduledThreadPoolExecutor(profile.getPoolSize(), threadFactory, rejectedExecutionHandler);
View Full Code Here

            queue = new LinkedBlockingQueue<Runnable>();
        } else {
            queue = new ArrayBlockingQueue<Runnable>(config.getQueueSize());
        }
        ThreadFactory factory = new DefaultThreadFactory(id, config.isThreadDaemon(), config.getThreadPriority());
        RejectedExecutionHandler handler = new ThreadPoolExecutor.CallerRunsPolicy();
        ThreadPoolExecutor service = new ThreadPoolExecutor(config.getCorePoolSize(),
                config.getMaximumPoolSize() < 0 ? Integer.MAX_VALUE : config.getMaximumPoolSize(), config
                        .getKeepAliveTime(), TimeUnit.MILLISECONDS, queue, factory, handler);
        if (config.isAllowCoreThreadsTimeout()) {
            try {
View Full Code Here

        badKeyWriterService.submit(new BadKeyWriter(badKeyFileOut, badKeyQOut));
        logger.info("Created badKeyWriter.");

        // Create ConsistencyFixWorker thread pool
        BlockingQueue<Runnable> blockingQ = new ArrayBlockingQueue<Runnable>(parallelism);
        RejectedExecutionHandler rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
        consistencyFixWorkers = new ThreadPoolExecutor(parallelism,
                                                       parallelism,
                                                       0L,
                                                       TimeUnit.MILLISECONDS,
                                                       blockingQ,
View Full Code Here

        min_threads, max_threads, keep_alive_time,
        TimeUnit.MILLISECONDS, queue);
    pool.setThreadFactory(factory);

    // default
    RejectedExecutionHandler handler = new ThreadPoolExecutor.CallerRunsPolicy();
    if (rejection_policy != null) {
      if (rejection_policy.equals("abort"))
        handler = new ThreadPoolExecutor.AbortPolicy();
      else if (rejection_policy.equals("discard"))
        handler = new ThreadPoolExecutor.DiscardPolicy();
View Full Code Here

TOP

Related Classes of java.util.concurrent.RejectedExecutionHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.