Package edu.emory.mathcs.backport.java.util.concurrent

Examples of edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor


    /**
     * Create the executor use the manage request processing threads
     */
    public ExecutorService newRequestExecutor(int port) {
        return new ThreadPoolExecutor(requestCoreThreadPoolSize, requestMaxThreadPoolSize,
                                      threadKeepAliveTime, threadKeepAliveTimeUnit,
                                      newRequestBlockingQueue(),
                                      new DefaultThreadFactory(
                                              new ThreadGroup("Connection thread group"),
                                              "HttpConnection-" + port));
View Full Code Here


    public BackportWorkerPool(int core, int max, int keepAlive,
        int queueLength, String threadGroupName, String threadGroupId) {

        log.debug("Using backport of the util.concurrent package..");
        executor = new ThreadPoolExecutor(
            core, max, keepAlive,
            TimeUnit.SECONDS,
            queueLength == -1 ?
                new LinkedBlockingQueue() :
                new LinkedBlockingQueue(queueLength),
View Full Code Here

   * assign a packer listener. This packet listener will trigger when a
   * message arrives.
   */
  public void start() throws AxisFault {
        // create thread pool of workers
       ExecutorService workerPool = new ThreadPoolExecutor(
                1,
                WORKERS_MAX_THREADS, WORKER_KEEP_ALIVE, TIME_UNIT,
                new LinkedBlockingQueue(),
                new org.apache.axis2.util.threadpool.DefaultThreadFactory(
                        new ThreadGroup("XMPP Worker thread group"),
View Full Code Here

    }
    if (!this.threadNamePrefixSet && this.beanName != null) {
      setThreadNamePrefix(this.beanName + "-");
    }
    BlockingQueue queue = createQueue(this.queueCapacity);
    this.threadPoolExecutor = new ThreadPoolExecutor(
        this.corePoolSize, this.maxPoolSize, this.keepAliveSeconds, TimeUnit.SECONDS,
        queue, this.threadFactory, this.rejectedExecutionHandler);
    if (this.allowCoreThreadTimeOut) {
      this.threadPoolExecutor.allowCoreThreadTimeOut(true);
    }
View Full Code Here

  public void initialize() {
    if (logger.isInfoEnabled()) {
      logger.info("Initializing ThreadPoolExecutor" + (this.beanName != null ? " '" + this.beanName + "'" : ""));
    }
    BlockingQueue queue = createQueue(this.queueCapacity);
    this.threadPoolExecutor = new ThreadPoolExecutor(
        this.corePoolSize, this.maxPoolSize, this.keepAliveSeconds, TimeUnit.SECONDS,
        queue, this.threadFactory, this.rejectedExecutionHandler);
  }
View Full Code Here

     *
     * @throws AxisFault
     */
    public void start() throws AxisFault {
        // create thread pool of workers
        workerPool = new ThreadPoolExecutor(
                1,
                WORKERS_MAX_THREADS, WORKER_KEEP_ALIVE, TIME_UNIT,
                new LinkedBlockingQueue(),
                new org.apache.axis2.util.threadpool.DefaultThreadFactory(
                        new ThreadGroup("JMS Worker thread group"),
View Full Code Here

    private ExecutorThreadModel(String threadNamePrefix) {
        this.threadNamePrefix = threadNamePrefix;

        // Create the default filter
        defaultFilter = new ExecutorFilter();
        ThreadPoolExecutor tpe = (ThreadPoolExecutor) defaultFilter
                .getExecutor();
        final ThreadFactory originalThreadFactory = tpe.getThreadFactory();
        ThreadFactory newThreadFactory = new ThreadFactory() {
            private final AtomicInteger threadId = new AtomicInteger(0);

            public Thread newThread(Runnable runnable) {
                Thread t = originalThreadFactory.newThread(
                        new NamePreservingRunnable(
                                runnable,
                                ExecutorThreadModel.this.threadNamePrefix + '-' +
                                threadId.incrementAndGet()));
                t.setDaemon(true);
                return t;
            }
        };
        tpe.setThreadFactory(newThreadFactory);

        // Set to default.
        setExecutor(null);
    }
View Full Code Here

    }

    protected ThreadPoolExecutor createDefaultExecutor(final String name,
                                                       final int priority,
                                                       final boolean daemon) {
        ThreadPoolExecutor rc = new ThreadPoolExecutor(5, Integer.MAX_VALUE, 10,
                TimeUnit.SECONDS, new SynchronousQueue(),
                new edu.emory.mathcs.backport.java.util.concurrent.ThreadFactory() {
            public Thread newThread(Runnable runnable) {
                Thread thread = new Thread(runnable, name);
                thread.setDaemon(daemon);
                thread.setPriority(priority);
                return thread;
            }
        });
        rc.allowCoreThreadTimeOut(true);
        return rc;
    }
View Full Code Here

    private boolean statsActive = true;
    private PoolStatsImpl stats = new PoolStatsImpl();
    private Map clients = new HashMap();

    public ThreadPool(int poolSize, String poolName, long keepAliveTime, ClassLoader classLoader, String objectName) {
        ThreadPoolExecutor p = new ThreadPoolExecutor(
            poolSize, // core size
            poolSize, // max size
            keepAliveTime, TimeUnit.MILLISECONDS,
            new SynchronousQueue());

        p.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
        p.setThreadFactory(new ThreadPoolThreadFactory(poolName, classLoader));
       
        try {
            this.objectName = ObjectName.getInstance(objectName);
        } catch (MalformedObjectNameException e) {
            throw new IllegalStateException("Bad object name injected: " + e.getMessage());
View Full Code Here

            };
        } else {
            command = runnable;
        }

        ThreadPoolExecutor p;
        synchronized (this) {
            p = executor;
        }
        if (p == null) {
            throw new IllegalStateException("ThreadPool has been stopped");
        }
        Runnable task = new ContextClassLoaderRunnable(command, classLoader);
        p.execute(task);
    }
View Full Code Here

TOP

Related Classes of edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor

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.