Package java.util.concurrent

Examples of java.util.concurrent.RejectedExecutionHandler


        final ThreadFactory threadFactory = new DaemonThreadFactory("StatelessPool.worker.");
        this.executor = new ThreadPoolExecutor(
            callbackThreads, callbackThreads * 2,
            1L, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>(qsize), threadFactory);

        this.executor.setRejectedExecutionHandler(new RejectedExecutionHandler() {
            @Override
            public void rejectedExecution(final Runnable r, final ThreadPoolExecutor tpe) {

                if (null == r || null == tpe || tpe.isShutdown() || tpe.isTerminated() || tpe.isTerminating()) {
                    return;
View Full Code Here


        int max = size;
        if (maxPoolSize != null) {
            max = CamelContextHelper.parseInteger(getCamelContext(), maxPoolSize);
        }

        RejectedExecutionHandler rejected = null;
        if (rejectedPolicy != null) {
            rejected = rejectedPolicy.asRejectedExecutionHandler();
        }

        long keepAlive = 60;
View Full Code Here

            Integer poolSize = profile.getPoolSize() != null ? profile.getPoolSize() : defaultProfile.getPoolSize();
            Integer maxPoolSize = profile.getMaxPoolSize() != null ? profile.getMaxPoolSize() : defaultProfile.getMaxPoolSize();
            Long keepAliveTime = profile.getKeepAliveTime() != null ? profile.getKeepAliveTime() : defaultProfile.getKeepAliveTime();
            TimeUnit timeUnit = profile.getTimeUnit() != null ? profile.getTimeUnit() : defaultProfile.getTimeUnit();
            Integer maxQueueSize = profile.getMaxQueueSize() != null ? profile.getMaxQueueSize() : defaultProfile.getMaxQueueSize();
            RejectedExecutionHandler handler = profile.getRejectedExecutionHandler() != null ? profile.getRejectedExecutionHandler() : defaultProfile.getRejectedExecutionHandler();
            // create the pool
            return newThreadPool(threadPoolProfileId, source, name, poolSize, maxPoolSize, keepAliveTime, timeUnit, maxQueueSize, handler, false);
        } else {
            // no profile with that id
            return null;
View Full Code Here

        int size = CamelContextHelper.parseInteger(camelContext, threadPoolDefinition.getPoolSize());
        int max = CamelContextHelper.parseInteger(camelContext, threadPoolDefinition.getMaxPoolSize());
        long keepAlive = CamelContextHelper.parseLong(camelContext, threadPoolDefinition.getKeepAliveTime());
        int queueSize = CamelContextHelper.parseInteger(camelContext, threadPoolDefinition.getMaxQueueSize());
        TimeUnit unit = threadPoolDefinition.getTimeUnit();
        RejectedExecutionHandler handler = threadPoolDefinition.getRejectedExecutionHandler();

        ExecutorService answer = camelContext.getExecutorServiceStrategy().newThreadPool(source, name,
                size, max, keepAlive, unit, queueSize, handler, true);
        return answer;
    }
View Full Code Here

            int core = getPoolSize() != null ? getPoolSize() : profile.getPoolSize();
            int max = getMaxPoolSize() != null ? getMaxPoolSize() : profile.getMaxPoolSize();
            long keepAlive = getKeepAliveTime() != null ? getKeepAliveTime() : profile.getKeepAliveTime();
            int maxQueue = getMaxQueueSize() != null ? getMaxQueueSize() : profile.getMaxQueueSize();
            TimeUnit tu = getTimeUnit() != null ? getTimeUnit() : profile.getTimeUnit();
            RejectedExecutionHandler rejected = profile.getRejectedExecutionHandler();
            if (rejectedPolicy != null) {
                rejected = rejectedPolicy.asRejectedExecutionHandler();
            }

            executorService = routeContext.getCamelContext().getExecutorServiceStrategy()
View Full Code Here

    private ThreadPoolExecutor workers;

    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

  private final int NUM_THREADS = 25;

  public AsynchronousLocalEngineRunner() {
    this.executor = new ThreadPoolExecutor(NUM_THREADS, NUM_THREADS, 30,
        TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),
        new RejectedExecutionHandler() {

          @Override
          public void rejectedExecution(Runnable workflow,
              ThreadPoolExecutor executor) {
            // TODO Auto-generated method stub
View Full Code Here

    } else {
      queue = new SynchronousQueue<>();
    }
    return new ThreadPoolExecutor(
        1, 1, 0L, TimeUnit.MILLISECONDS, queue, makeThreadFactory(nameFormat),
        new RejectedExecutionHandler()
        {
          @Override
          public void rejectedExecution(Runnable r, ThreadPoolExecutor executor)
          {
            try {
View Full Code Here

        {
            if ( executor.isShutdown() )
            {
                Scheduler.this.stop( null, null, true, false );
            }
            final RejectedExecutionHandler poolHandler = this.poolHandler;
            if ( poolHandler != null )
            {
                poolHandler.rejectedExecution( r, executor );
            }
        }
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

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.