The list of methods to do ThreadPoolExecutor are organized into topic(s).
ThreadPoolExecutor
createExecutor() create Executor
return createExecutor(8, 32);
ThreadPoolExecutor
createExecutor(final String name, int count, int keepAlive, final boolean isDaemon) create Executor
ThreadPoolExecutor exe = new ThreadPoolExecutor(count, count, keepAlive, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
private int threadNum = 1;
public Thread newThread(Runnable r) {
Thread t = new Thread(r, name + (threadNum++));
t.setDaemon(isDaemon);
return t;
});
return exe;
BlockingQueue
createQueue(final int queueCapacity)
Create the BlockingQueue to use for the ThreadPoolExecutor.
if (queueCapacity > 0) {
return new LinkedBlockingQueue<Runnable>(queueCapacity);
return new SynchronousQueue<Runnable>();
ScheduledThreadPoolExecutor
createScheduledThreadPoolExecutor(final int poolSz, final String threadName) create Scheduled Thread Pool Executor
return new ScheduledThreadPoolExecutor(poolSz, new ThreadFactory() {
private AtomicInteger threadNum = new AtomicInteger(0);
@Override
public Thread newThread(Runnable r) {
if (poolSz == 1)
return new Thread(r, threadName);
else
return new Thread(r, threadName + threadNum.incrementAndGet());
...
ThreadPoolExecutor
createThreadPoolExecutor(final int queueSize, final String threadName) create Thread Pool Executor
ThreadFactory threadFactory = new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = new Thread(r, threadName);
t.setDaemon(true);
return t;
};
int processors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
...
void
executeInBackground(Runnable r) execute In Background
if (backgroundExecutor == null) {
backgroundExecutor = new ThreadPoolExecutor(0, 1, 1, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("BackgroundExecutor");
t.setPriority(Thread.MIN_PRIORITY);
...
void
executeInDaemon(Runnable... run) execute In Daemon
int i = run.length;
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(i, new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread();
t.setDaemon(true);
return t;
});
while (--i >= 0) {
executor.scheduleAtFixedRate(run[i], 0, 40, TimeUnit.MILLISECONDS);
Executor
getBlockingWorkExecutor() Get Executor for long term and potentially blocking operations.
if (BLOCKING_EXECUTOR == null) {
final ThreadGroup tg = new ThreadGroup("Blocking-Work-Executor-Group");
final AtomicInteger counter = new AtomicInteger(0);
ThreadFactory tf = new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(tg, r, "Blocking-Work-Executor-" + (counter.incrementAndGet()));
t.setDaemon(true);
...
ScheduledThreadPoolExecutor
getScheduler() Returns scheduled thread-pool executor used for scheduling and execution of timer ticks.
synchronized (getJPAZLock()) {
if (tickExecutor == null) {
tickExecutor = new ScheduledThreadPoolExecutor(1);
return tickExecutor;