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

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


                    this.minimumPoolSize.getValue() + " createThreads=" + this.createThreads.getValue() + " threadLifetime=" + this.threadLifetime + "' ms");

      // this.pool = new PooledExecutor(new LinkedQueue());
      if (this.minimumPoolSize.getValue() < 3)
         log.warning("The minimumPoolSize of '" + this.minimumPoolSize.getValue() + "' is less than 2: if one single callback blocks it could block all other callbacks");
      this.pool = new PooledExecutor();
      this.pool.setThreadFactory(new DeamonThreadFactory(glob.getId(), this.threadPrio.getValue()));
      this.pool.setMaximumPoolSize(this.maximumPoolSize.getValue());
      this.pool.setMinimumPoolSize(this.minimumPoolSize.getValue());
      this.pool.createThreads(this.createThreads.getValue());
      this.pool.setKeepAliveTime(this.threadLifetime.getValue());
View Full Code Here


      viewExecutor = new QueuedExecutor();

      this.jChannelFactory = JChannelFactory;
     
      this.pooledExecutor = new PooledExecutor(new LinkedQueue(), poolSize);
     
      this.pooledExecutor.setMinimumPoolSize(poolSize);
   }
View Full Code Here

    private PooledExecutor executor;
    private ClassLoader classLoader;
    private ObjectName objectName;

    public ThreadPool(int poolSize, String poolName, long keepAliveTime, ClassLoader classLoader, String objectName) {
        PooledExecutor p = new PooledExecutor(poolSize);
        p.abortWhenBlocked();
        p.setKeepAliveTime(keepAliveTime);
        p.setMinimumPoolSize(poolSize);
        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

    public String getObjectName() {
        return objectName.getCanonicalName();
    }

    public void execute(Runnable command) throws InterruptedException {
        PooledExecutor 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

    public void doStart() throws Exception {
    }

    public void doStop() throws Exception {
        PooledExecutor p;
        synchronized(this) {
            p = executor;
            executor = null;
            classLoader = null;
        }
        if (p != null) {
            p.shutdownNow();
        }
    }
View Full Code Here

      passUp(new Event(Event.RESUME));
   }

   private PooledExecutor setupThreadPool()
   {
      PooledExecutor threadPool = new PooledExecutor(max_pool);
      threadPool.waitWhenBlocked();
      threadPool.setMinimumPoolSize(1);
      threadPool.setKeepAliveTime(pool_thread_keep_alive);
      threadPool.setThreadFactory(new ThreadFactory()
      {

         public Thread newThread(final Runnable command)
         {
            synchronized (poolLock)
View Full Code Here

    static int count;
    private final Object poolLock = new Object();
    public void testPool() throws InterruptedException {
      long keepAlive = 30*1000;
        PooledExecutor executor = new PooledExecutor(5);
        executor.setMinimumPoolSize(1);
        executor.waitWhenBlocked();
        executor.setKeepAliveTime(keepAlive);
        executor.setThreadFactory(new ThreadFactory() {
            public Thread newThread(final Runnable command) {
              synchronized (poolLock) {
                    count++;
                }
                return new Thread("poolid=" +count) {
                 
                    public void run() {
                       System.out.println("Thread " + Thread.currentThread() + " started");
                        command.run();
                        System.out.println("Thread " + Thread.currentThread() + " stopped");
                    }
                };
            }
        });
        for (int i = 0; i < 30; i++) {
            final int count = i;
            executor.execute(new Runnable() {
                public void run() {
                    System.out.println("Runnable " + count + " running");
                    //use timing here that approximates how long
                    //this thread needs to run
                    Util.sleep(3000);
                }
            });
           
            //use timing here that approximates time
            //between tasks arriving
            Util.sleep(1000);
        }
        executor.shutdownAfterProcessingCurrentlyQueuedTasks();
        //see if all threads are stop/recycled
        Util.sleep(keepAlive);
    }
View Full Code Here

    private PoolStatsImpl stats = new PoolStatsImpl();
    private Map clients = new HashMap();


    public ThreadPool(int poolSize, String poolName, long keepAliveTime, ClassLoader classLoader, String objectName) {
        PooledExecutor p = new PooledExecutor(poolSize);
        p.abortWhenBlocked();
        p.setKeepAliveTime(keepAliveTime);
        p.setMinimumPoolSize(poolSize);
        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;
        }

        PooledExecutor 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

    public void doStart() throws Exception {
    }

    public void doStop() throws Exception {
        PooledExecutor p;
        synchronized (this) {
            p = executor;
            executor = null;
            classLoader = null;
        }
        if (p != null) {
            p.shutdownNow();
        }
    }
View Full Code Here

TOP

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

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.