Package EDU.oswego.cs.dl.util.concurrent

Examples of EDU.oswego.cs.dl.util.concurrent.PooledExecutor


     * one.
     *
     * @param maxSize Maximum size of the work executor pool.
     */
    public WorkExecutorPoolImpl(int maxSize) {
        pooledExecutor = new PooledExecutor(new LinkedQueue(), maxSize);
        pooledExecutor.setMinimumPoolSize(maxSize);
        pooledExecutor.waitWhenBlocked();
    }
View Full Code Here


     * @param maxSize Maximum size of the work executor pool.
     */
    public WorkExecutorPoolImpl(
            Channel channel,
            int maxSize) {
        pooledExecutor = new PooledExecutor(channel, maxSize);
        pooledExecutor.setMinimumPoolSize(maxSize);
        pooledExecutor.waitWhenBlocked();
    }
View Full Code Here

        EventHandler handler = pipeline.getEventHandler();
        List sourceList = new ArrayList(sources.length);

        for (int i = 0; i < sources.length; i++)
        {
            PooledExecutor threadPool = new PooledExecutor();
            threadPool.setMinimumPoolSize(1);
            threadPool.setMaximumPoolSize(m_maxThreadsPerPool);
            SourceRunner initRunner = new SourceRunner(sources[i], handler);

            try
            {
                threadPool.execute(initRunner);
            }
            catch ( InterruptedException e )
            {
            }
View Full Code Here

        {
            throw new IllegalStateException( "ThreadManager is already initailized" );
        }

        final int maxPoolSize = Math.max(( m_processors * m_threadsPerProcessor ) + 1, m_processors + 1);
        m_threadPool = new PooledExecutor( m_processors + 1 );
        m_threadPool.setMinimumPoolSize( 2 ); // at least two threads
        m_threadPool.setMaximumPoolSize( maxPoolSize );
        m_threadPool.waitWhenBlocked();
        m_threadPool.setThreadFactory( new ThreadFactory() {
            public Thread newThread(Runnable run) {
View Full Code Here

        if (executor instanceof Service) {
            Service service = (Service) executor;
            service.stop();
        }
        else if (executor instanceof PooledExecutor) {
            PooledExecutor pe = (PooledExecutor) executor;
            pe.shutdownAfterProcessingCurrentlyQueuedTasks();
            //pe.shutdownNow();
            // Wait up to 5 seconds of the threads to shutdown..
            pe.awaitTerminationAfterShutdown(1000*5);
        }
        else if (executor != null) {
            log.warn("Don't know how to cleanly close down the given executor: " + executor
                    + ". Consider deriving from this class to implement the Service interface to shut down cleanly");
        }
View Full Code Here

        final int keepAliveTime,

        final boolean waitWhenBlocked) {

        m_threadPool = new PooledExecutor(new BoundedBuffer(threadPoolInitSize), threadPoolMaxSize);

        m_threadPool.setKeepAliveTime(keepAliveTime);

        m_threadPool.createThreads(threadPoolInitSize);
View Full Code Here

        final int threadPoolInitSize,

        final int keepAliveTime) {

        m_threadPool = new PooledExecutor(new LinkedQueue());

        m_threadPool.setKeepAliveTime(keepAliveTime);

        m_threadPool.createThreads(threadPoolInitSize);
View Full Code Here

        if (backLog <= 0) {
            c = new SynchronousChannel();
        } else {
            c = new BoundedLinkedQueue(backLog);
        }
        this.executor = new PooledExecutor(c, poolSize);
        this.executor.setMinimumPoolSize(poolSize);
        this.executor.setBlockedExecutionHandler(
                new PooledExecutor.BlockedExecutionHandler() {
            public boolean blockedAction(Runnable command) {
                // execute with current thread and log message
View Full Code Here

        if (backLog <= 0) {
            c = new SynchronousChannel();
        } else {
            c = new BoundedLinkedQueue(backLog);
        }
        this.executor = new PooledExecutor(c, poolSize);
        this.executor.setMinimumPoolSize(poolSize);
        this.executor.setBlockedExecutionHandler(
                new PooledExecutor.BlockedExecutionHandler() {
            public boolean blockedAction(Runnable command) {
                // execute with current thread and log message
View Full Code Here

        this(null, numThreads);
    }

    public ConcurrentTestSuite(String name, int numThreads) {
        super(name);
        executor = new PooledExecutor(numThreads) {
            {
                waitWhenBlocked();
            }
        };
    }
View Full Code Here

TOP

Related Classes of EDU.oswego.cs.dl.util.concurrent.PooledExecutor

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.