Java ThreadPoolExecutor getBoundedThreadPoolExecutor(int maxPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory tFactory)

Here you can find the source of getBoundedThreadPoolExecutor(int maxPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory tFactory)

Description

Create a bounded thread pool executor.

License

Open Source License

Parameter

Parameter Description

Declaration

public static ThreadPoolExecutor getBoundedThreadPoolExecutor(int maxPoolSize, long keepAliveTime,
        TimeUnit unit, ThreadFactory tFactory) 

Method Source Code

//package com.java2s;
/* This file is part of VoltDB.
 * Copyright (C) 2008-2015 VoltDB Inc.//from  ww  w  .j a  va  2  s. c  om
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with VoltDB.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Main {
    /**
     * Create a bounded thread pool executor. The work queue is synchronous and can cause
     * RejectedExecutionException if there is no available thread to take a new task.
     * @param maxPoolSize: the maximum number of threads to allow in the pool.
     * @param keepAliveTime: when the number of threads is greater than the core, this is the maximum
     *                       time that excess idle threads will wait for new tasks before terminating.
     * @param unit: the time unit for the keepAliveTime argument.
     * @param threadFactory: the factory to use when the executor creates a new thread.
     */
    public static ThreadPoolExecutor getBoundedThreadPoolExecutor(int maxPoolSize, long keepAliveTime,
            TimeUnit unit, ThreadFactory tFactory) {
        return new ThreadPoolExecutor(0, maxPoolSize, keepAliveTime, unit, new SynchronousQueue<Runnable>(),
                tFactory);
    }
}

Related

  1. createScheduledThreadPoolExecutor(final int poolSz, final String threadName)
  2. createThreadPoolExecutor(final int queueSize, final String threadName)
  3. executeInBackground(Runnable r)
  4. executeInDaemon(Runnable... run)
  5. getBlockingWorkExecutor()
  6. getScheduler()
  7. getThreadPoolExecutor(int poolSize, int[] poolInfo)
  8. getThreadPoolTrace(ThreadPoolExecutor threadpool)
  9. getWorkerCount(ThreadPoolExecutor workerExecutor)