Package java.util.concurrent

Examples of java.util.concurrent.RejectedExecutionHandler


        if (poolSize == null || poolSize <= 0) {
            throw new IllegalArgumentException("PoolSize must be a positive number");
        }

        int max = getMaxPoolSize() != null ? getMaxPoolSize() : getPoolSize();
        RejectedExecutionHandler rejected = null;
        if (rejectedPolicy != null) {
            rejected = rejectedPolicy.asRejectedExecutionHandler();
        }

        ExecutorService answer = camelContext.getExecutorServiceStrategy().newThreadPool(getId(), getThreadName(), getPoolSize(), max,
View Full Code Here


                        Thread t = new Thread(r);
                        t.setContextClassLoader(classLoader);
                        return t;
                    }
                }).build();
        RejectedExecutionHandler rejectedExecutionHandler = new RejectedExecutionHandler() {

            @Override
            public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                metrics.droppedEvent(name);
            }
View Full Code Here

    public ExecutorService create() {
        boolean remote = (this instanceof RemoteSendersExecutorServiceFactory);
        ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true)
                .setNameFormat(remote ? "remote-sender-%d" : "sender-%d").build();

        RejectedExecutionHandler rejectedExecutionHandler = (remote ? new RejectedExecutionHandler() {

            // from a remote sender
            @Override
            public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                metrics.droppedEventInRemoteSender();
            }
        } : new RejectedExecutionHandler() {

            @Override
            public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                metrics.droppedEventInSender();
            }
View Full Code Here

  public ActivityProcessor() {
    messageMonitors = new ArrayList<List<MessageMonitor>>(20);
    workers = new ThreadPoolExecutor(2, Runtime.getRuntime().availableProcessors(), 30, TimeUnit.SECONDS,
            new ArrayBlockingQueue<Runnable>(500, false));
    workers.setRejectedExecutionHandler(new RejectedExecutionHandler() {
      public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        // just run on calling thread.
        r.run();
      }
    });
View Full Code Here

            th.start();
        }*/


        final BlockingQueue<Runnable> worksQueue = new ArrayBlockingQueue<Runnable>(pageLinks.size());
        final RejectedExecutionHandler executionHandler = new TaskOverflowHandler();
        LOG.info("Starting Pool: Threads: " + POOL_SIZE);
        // Create the ThreadPoolExecutor
        final ThreadPoolExecutor executor =
                new ThreadPoolExecutor(POOL_SIZE, POOL_SIZE, 3, TimeUnit.SECONDS, worksQueue, executionHandler);
        executor.allowCoreThreadTimeOut(true);
View Full Code Here

    public DefaultCommunicationClientImpl(CommunicationConnectionFactory factory){
        this.factory = factory;
    }

    public void initial() {
        RejectedExecutionHandler handler = null;
        if (discard) {
            handler = new ThreadPoolExecutor.DiscardPolicy();
        } else {
            handler = new ThreadPoolExecutor.AbortPolicy();
        }
View Full Code Here

     * @return a new BlockingThreadPoolExecutor
     */
    public ThreadPoolExecutor newInstance() {
       
        final BlockingQueue<Runnable> workQueue = new SynchronousQueue<Runnable>();
        RejectedExecutionHandler rejectedExecutionHandler = new CallerRunsUnlessPoolShutdownPolicy();
       
        ThreadFactory tf = new MyThreadFactory();
       
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                corePoolSize, maxPoolSize, keepAliveTimeMillis, TimeUnit.MILLISECONDS,
View Full Code Here

  /**
   * Creates a new task executor
   */
  public TaskExecutor() {
    executor.setRejectedExecutionHandler(new RejectedExecutionHandler() {

      @Override
      public void rejectedExecution(Runnable r, ThreadPoolExecutor ex) {
        // if rejected delay task
        System.out.println("Rejected: " + r + " <-- delayed!");
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 RejectableScheduledThreadPoolExecutor(profile.getPoolSize(), threadFactory, rejectedExecutionHandler);
View Full Code Here

                Thread t = new Thread(r);
                t.setName("CHMQ-RemoteQueueTransfer-" + sequence.getAndIncrement());
                t.setDaemon(true);
                return t;
            }
      }, new RejectedExecutionHandler() {
        public void rejectedExecution(Runnable r,
              ThreadPoolExecutor executor) {
      logger.warn("Rejected execution of {} by executor with {} current threads in the pool", r.getClass().getName(), executor.getPoolSize());
        }
    });
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.