List of utility methods to do Thread Executor Pool
void | clearPreloadThreads() clear Preload Threads executorService.shutdown(); executorService = Executors.newCachedThreadPool(); |
ThreadPoolExecutor | createBoundedCachedThreadPool(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit timeUnit) Creates a ThreadPool for running requests threads. @SuppressWarnings("serial") final LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>() { public boolean offer(final Runnable r) { if (size() > 1) { return false; return super.offer(r); }; ... |
ExecutorService | createClientThreadPool(int numThreads, int queueSize) This creates the client side thread pool for WXS. LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(queueSize); ExecutorService p = new ThreadPoolExecutor(numThreads, numThreads, 2L, TimeUnit.MINUTES, queue, new ThreadPoolExecutor.CallerRunsPolicy()); return p; |
ExecutorService | createPool(int threads, int queueSize) create Pool return new ThreadPoolExecutor(1, threads, 30, TimeUnit.SECONDS, new LinkedBlockingDeque<>(queueSize), new ThreadPoolExecutor.CallerRunsPolicy()); |
ExecutorService | createPooledExecutorService(int poolSize, final String namePrefix) Creates a pooled ExecutorService of a fixed size and turns all threads to daemons to make sure they do not block application shutdown. return Executors.newFixedThreadPool(poolSize, new ThreadFactory() { final AtomicInteger counter = new AtomicInteger(0); @Override public Thread newThread(Runnable runnable) { final Thread thread = new Thread(runnable); thread.setDaemon(true); thread.setName(String.format("%s-%d", namePrefix, counter.incrementAndGet())); return thread; ... |
ThreadPoolExecutor | getPool() get Pool return POOL;
|
ExecutorService | getPool() get Pool return ForkJoinTask.getPool();
|
ExecutorService | getQueuedThreadPool(double threadToCpuRatio, int queueCapacity) get Queued Thread Pool int workingThreads = Double.valueOf(NUM_CPU * threadToCpuRatio).intValue(); return new ThreadPoolExecutor(workingThreads, workingThreads, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(queueCapacity), new ThreadPoolExecutor.CallerRunsPolicy()); |
ExecutorService | getRecheckThreadPool() Returns the MX recheck ThreadPool. if (recheckThreadPool == null) { recheckThreadPool = createBoundedCachedThreadPool(0, CONST_10, CONST_60, TimeUnit.SECONDS); return recheckThreadPool; |
ExecutorService | getThreadPool() retrieves a cached thread pool if (threadPool == null) { threadPool = Executors.newCachedThreadPool(); return threadPool; |