Examples of ThreadPoolExecutor


Examples of java.util.concurrent.ThreadPoolExecutor

    }

    public static ThreadPoolExecutor newFixedThreadPool(int nThreads, String threadName, int threadPriority, boolean daemon) {
        NamedThreadFactory factory = new NamedThreadFactory(threadName, daemon);
        factory.setPriority(threadPriority);
        return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), factory);
    }
View Full Code Here

Examples of java.util.concurrent.ThreadPoolExecutor

        factory.setPriority(threadPriority);
        return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), factory);
    }

    public static ThreadPoolExecutor newThreadPool(int corePoolSize, int maxPoolSize, String threadName) {
        return new ThreadPoolExecutor(corePoolSize, maxPoolSize, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(threadName));
    }
View Full Code Here

Examples of java.util.concurrent.ThreadPoolExecutor

    public static ThreadPoolExecutor newThreadPool(int corePoolSize, int maxPoolSize, String threadName) {
        return new ThreadPoolExecutor(corePoolSize, maxPoolSize, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(threadName));
    }

    public static ThreadPoolExecutor newThreadPool(int corePoolSize, int maxPoolSize, long keepAliveInSec, String threadName) {
        return new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveInSec, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(threadName));
    }
View Full Code Here

Examples of java.util.concurrent.ThreadPoolExecutor

    public static ThreadPoolExecutor newThreadPool(int corePoolSize, int maxPoolSize, long keepAliveInSec, String threadName) {
        return new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveInSec, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(threadName));
    }

    public static ThreadPoolExecutor newThreadPool(int corePoolSize, int maxPoolSize, long keepAliveInSec, String threadName, boolean daemon) {
        return new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveInSec, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(threadName, daemon));
    }
View Full Code Here

Examples of java.util.concurrent.ThreadPoolExecutor

    /**
     * @param numberOfThreads
     */
    public Jdk15ThreadPool(int numberOfThreads)
    {
        _execService = new ThreadPoolExecutor( numberOfThreads, numberOfThreads, 0L, TimeUnit.MILLISECONDS,
                                               new LinkedBlockingQueue(), new EJThreadFactory() );
    }
View Full Code Here

Examples of java.util.concurrent.ThreadPoolExecutor

     * @param threadGroup
     * @param numberOfThreads
     */
    public Jdk15ThreadPool(final ThreadGroup threadGroup, int numberOfThreads)
    {
        _execService = new ThreadPoolExecutor( numberOfThreads, numberOfThreads, 0L, TimeUnit.MILLISECONDS,
                                               new LinkedBlockingQueue(), new EJThreadFactory( threadGroup ) );
        // _execService.prestartAllCoreThreads();
    }
View Full Code Here

Examples of java.util.concurrent.ThreadPoolExecutor

            queue = new LinkedBlockingQueue<Runnable>();
        } else {
            // bounded task queue
            queue = new LinkedBlockingQueue<Runnable>(maxQueueSize);
        }
        ThreadPoolExecutor answer = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, queue);
        answer.setThreadFactory(new ThreadFactory() {
            public Thread newThread(Runnable r) {
                Thread answer = new Thread(r, getThreadName(pattern, name));
                answer.setDaemon(daemon);
                return answer;
            }
        });
        if (rejectedExecutionHandler == null) {
            rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
        }
        answer.setRejectedExecutionHandler(rejectedExecutionHandler);
        return answer;
    }
View Full Code Here

Examples of java.util.concurrent.ThreadPoolExecutor

   * @param poolSize
   * @param maxPoolSize
   * @param keepAliveTime
   */
  public ThreadPoolTaskExecutor(int poolSize, int maxPoolSize, int keepAliveTime) {
    threadPool = new ThreadPoolExecutor(poolSize, maxPoolSize, keepAliveTime, TimeUnit.SECONDS, queue);
  }
View Full Code Here

Examples of java.util.concurrent.ThreadPoolExecutor

      }
      BlockingQueue<Runnable> queue = workQueue == null ? new LinkedBlockingQueue<Runnable>() : workQueue;
      ThreadFactory factory = threadFactory == null ? DEFAULT_THREAD_FACTORY : threadFactory;
      RejectedExecutionHandler handler = rejectedExecutionHandler == null ? DEFAULT_REJECTED_EXECUTION_HANDLER : rejectedExecutionHandler;
     
      return new ThreadPoolExecutor(coreSize, maxSize, keepAliveTime, keepAliveTimeUnit, queue, factory, handler);
   }
View Full Code Here

Examples of java.util.concurrent.ThreadPoolExecutor

      throw new IllegalArgumentException("threadCount [" + threadCount
          + "] must be > 0.");

    // Adjust the service if we can, otherwise replace it.
    if (AsyncScalr.service instanceof ThreadPoolExecutor) {
      ThreadPoolExecutor tpe = (ThreadPoolExecutor) AsyncScalr.service;

      // Set the new min/max thread counts for the pool.
      tpe.setCorePoolSize(threadCount);
      tpe.setMaximumPoolSize(threadCount);
    } else
      setService(Executors.newFixedThreadPool(threadCount));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.