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

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


    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


    /**
     * Creates a new instace with the default thread pool implementation
     * (<tt>new ThreadPoolExecutor(16, 16, 60, TimeUnit.SECONDS, new LinkedBlockingQueue() )</tt>).
     */
    public ExecutorFilter() {
        this(new ThreadPoolExecutor(16, 16, 60, TimeUnit.SECONDS,
                new LinkedBlockingQueue()));
    }
View Full Code Here

        if (queueCapacity > 0) {
            queue = new LinkedBlockingQueue(queueCapacity);
        } else {
            queue = new SynchronousQueue();
        }
        return new ThreadPoolExecutor(corePoolSize, maxPoolSize,
                keepAliveSeconds, TimeUnit.SECONDS, queue, threadFactory,
                rejectedExecutionHandler);
    }
View Full Code Here

                keepAliveSeconds, TimeUnit.SECONDS, queue, threadFactory,
                rejectedExecutionHandler);
    }

    protected void destroyInstance(Object o) throws Exception {
        ThreadPoolExecutor executor = (ThreadPoolExecutor) o;
        executor.shutdown();
    }
View Full Code Here

    {
        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( runnable );
                t.setName( ExecutorThreadModel.this.threadNamePrefix + '-' + threadId.incrementAndGet() );
                t.setDaemon( true );
                return t;
            }
        };
        tpe.setThreadFactory( newThreadFactory );
       
        // Set to default.
        setExecutor( null );
    }
View Full Code Here

        }
        else
        {
            queue = new SynchronousQueue();
        }
        return new ThreadPoolExecutor(
                corePoolSize, maxPoolSize, keepAliveSeconds, TimeUnit.SECONDS,
                queue, threadFactory, rejectedExecutionHandler );
    }
View Full Code Here

                queue, threadFactory, rejectedExecutionHandler );
    }

    protected void destroyInstance( Object o ) throws Exception
    {
        ThreadPoolExecutor executor = ( ThreadPoolExecutor ) o;
        executor.shutdown();
    }
View Full Code Here

     * Creates a new instace with the default thread pool implementation
     * (<tt>new ThreadPoolExecutor(16, 16, 60, TimeUnit.SECONDS, new LinkedBlockingQueue() )</tt>).
     */
    public ExecutorFilter()
    {
        this( new ThreadPoolExecutor(16, 16, 60, TimeUnit.SECONDS, new LinkedBlockingQueue() ) );
    }
View Full Code Here

*/
public class ExecutorThreadModelFactoryBeanTest extends TestCase
{
    public void testSuccessfulCreationWithExecutor() throws Exception
    {
        Executor executor = new ThreadPoolExecutor( 1, 10, 3600, TimeUnit.SECONDS, new SynchronousQueue() );
        ExecutorThreadModelFactoryBean factory = new  ExecutorThreadModelFactoryBean();
        factory.setServiceName( "foo" );
        factory.setExecutor( executor );
        factory.afterPropertiesSet();
        ExecutorThreadModel threadModel = ( ExecutorThreadModel ) factory.getObject();
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

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.