use of java.util.concurrent.ThreadPoolExecutor in project es6draft by anba.
the class RuntimeWorkerThreadFactory method createWorkerThreadPoolExecutor.
/**
* Returns a new {@link ThreadPoolExecutor} to create runtime worker threads.
*
* @return a new {@link ThreadPoolExecutor} for runtime worker threads
*/
static ThreadPoolExecutor createWorkerThreadPoolExecutor() {
String name = "runtimeworker-" + runtimeWorkerCount.incrementAndGet();
ThreadPoolExecutor executor = new ThreadPoolExecutor(WORKER_THREAD_CORE_SIZE, WORKER_THREAD_POOL_SIZE, WORKER_THREAD_POOL_TTL, TimeUnit.SECONDS, new SynchronousQueue<>(), new RuntimeWorkerThreadFactory(name));
executor.allowCoreThreadTimeOut(true);
return executor;
}
use of java.util.concurrent.ThreadPoolExecutor in project es6draft by anba.
the class RuntimeWorkerThreadFactory method createThreadPoolExecutor.
/**
* Returns a new {@link ThreadPoolExecutor} to create runtime threads.
*
* @return a new {@link ThreadPoolExecutor} for runtime threads
*/
static ThreadPoolExecutor createThreadPoolExecutor() {
String name = "runtime-" + runtimeCount.incrementAndGet();
ThreadPoolExecutor executor = new ThreadPoolExecutor(THREAD_POOL_SIZE, THREAD_POOL_SIZE, THREAD_POOL_TTL, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new RuntimeWorkerThreadFactory(name));
executor.allowCoreThreadTimeOut(true);
return executor;
}
use of java.util.concurrent.ThreadPoolExecutor in project otter by alibaba.
the class DbLoadAction method adjustPoolSize.
// 调整一下线程池
private void adjustPoolSize(DbLoadContext context) {
Pipeline pipeline = context.getPipeline();
int newPoolSize = pipeline.getParameters().getLoadPoolSize();
if (newPoolSize != poolSize) {
poolSize = newPoolSize;
if (executor instanceof ThreadPoolExecutor) {
ThreadPoolExecutor pool = (ThreadPoolExecutor) executor;
pool.setCorePoolSize(newPoolSize);
pool.setMaximumPoolSize(newPoolSize);
}
}
}
use of java.util.concurrent.ThreadPoolExecutor in project otter by alibaba.
the class DatabaseExtractor method adjustPoolSize.
// 调整一下线程池
private void adjustPoolSize(int newPoolSize) {
if (newPoolSize != poolSize) {
poolSize = newPoolSize;
if (executor instanceof ThreadPoolExecutor) {
ThreadPoolExecutor pool = (ThreadPoolExecutor) executor;
pool.setCorePoolSize(newPoolSize);
pool.setMaximumPoolSize(newPoolSize);
}
}
}
use of java.util.concurrent.ThreadPoolExecutor in project otter by alibaba.
the class FileLoadAction method adjustPoolSize.
private void adjustPoolSize(FileLoadContext context) {
Pipeline pipeline = context.getPipeline();
int newPoolSize = pipeline.getParameters().getFileLoadPoolSize();
if (newPoolSize != poolSize) {
poolSize = newPoolSize;
if (executor instanceof ThreadPoolExecutor) {
ThreadPoolExecutor pool = (ThreadPoolExecutor) executor;
pool.setCorePoolSize(newPoolSize);
pool.setMaximumPoolSize(newPoolSize);
}
}
}
Aggregations