Package java.util.concurrent

Examples of java.util.concurrent.RejectedExecutionHandler


            final BlockingQueue<Runnable> workQueue = queueCapacity > 0 ?
                    new LinkedBlockingQueue<Runnable>(queueCapacity) : new SynchronousQueue<Runnable>(true);

            final String rejectionPolicyProp = configProperties.getProperty(THREAD_POOL_REJECTION_POLICY);
            RejectedExecutionHandler rejectionHandler = null;

            if (rejectionPolicyProp != null && !rejectionPolicyProp.isEmpty()) {
                try {
                    final Class<?> aClass = getClassLoader().loadClass(rejectionPolicyProp.trim());
                    rejectionHandler = (RejectedExecutionHandler) aClass.newInstance();
View Full Code Here


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

        cachedExecutorService = new ThreadPoolExecutor(
                CORE_POOL_SIZE, Integer.MAX_VALUE, KEEP_ALIVE_TIME, 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

    }

    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

      public Thread newThread(Runnable r) {
        return new Thread(r, "firefly business logic thread");
      }
    };
   
    RejectedExecutionHandler handler = new RejectedExecutionHandler(){

      @SuppressWarnings("unchecked")
      @Override
      public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
       
View Full Code Here

        } else {
          return offerLast(r);
        }
      }
    });
    pool.setRejectedExecutionHandler(new RejectedExecutionHandler() {
      @Override
      public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
        log.debug("{} thread queue full, waiting...", poolName);
        try {
          Task task = (Task) r;
View Full Code Here

      @Override
      public Thread newThread(Runnable r) {
        return new Thread(r, "firefly http handler thread");
      }
    };
    RejectedExecutionHandler handler = new RejectedExecutionHandler(){

      @SuppressWarnings("unchecked")
      @Override
      public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        Task task = (Task) ((MyFutureTask<Void>)r).getCurrentRunnable();
View Full Code Here

                            LOG.error("Error in thread '{}'", t.getName(), e);
                        }
                    });
                    return thread;
                }
            }, new RejectedExecutionHandler() {
                @Override
                public void rejectedExecution(final Runnable r, final ThreadPoolExecutor executor) {
                    try {
                        executor.getQueue().offer(r, 60, TimeUnit.SECONDS);
                    } catch (InterruptedException e) {
View Full Code Here

    /**
     * @return
     */
    private Thread preparePool() {
        RejectedExecutionHandler policy = new CallerBlocksPolicy();
        int threads = options.getThreadCount();
        // an array queue should be somewhat lighter-weight
        BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(
                options.getQueueSize());
        pool = new ThreadPoolExecutor(threads, threads, 16,
View Full Code Here

        this.mode = mode;
    }

    public void initital() {
        if (isInit == false) {
            RejectedExecutionHandler handler = getHandler(mode);
            BlockingQueue queue = getBlockingQueue(acceptCount, mode);
            // 构造pool池
            this.pool = new AsyncLoadThreadPool(poolSize, poolSize, 0L, TimeUnit.MILLISECONDS, queue,
                                                new NamedThreadFactory(), handler);
View Full Code Here

            final BlockingQueue<Runnable> workQueue = queueCapacity > 0 ?
                    new LinkedBlockingQueue<Runnable>(queueCapacity) : new SynchronousQueue<Runnable>(true);

            final String rejectionPolicyProp = configProperties.getProperty(THREAD_POOL_REJECTION_POLICY);
            RejectedExecutionHandler rejectionHandler = null;

            if (rejectionPolicyProp != null && !rejectionPolicyProp.isEmpty()) {
                try {
                    final Class<?> aClass = getClassLoader().loadClass(rejectionPolicyProp.trim());
                    rejectionHandler = (RejectedExecutionHandler) aClass.newInstance();
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.