use of org.wildfly.clustering.service.concurrent.ClassLoaderThreadFactory in project wildfly by wildfly.
the class ScheduledThreadPoolBuilder method configure.
@Override
public Builder<ThreadPoolConfiguration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
int maxThreads = this.definition.getMaxThreads().resolveModelAttribute(context, model).asInt();
long keepAliveTime = this.definition.getKeepAliveTime().resolveModelAttribute(context, model).asLong();
ThreadPoolExecutorFactory<?> factory = new ThreadPoolExecutorFactory<ScheduledExecutorService>() {
@Override
public ScheduledExecutorService createExecutor(ThreadFactory factory) {
// Use fixed size, based on maxThreads
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(maxThreads, new ClassLoaderThreadFactory(factory, ClassLoaderThreadFactory.class.getClassLoader()));
executor.setKeepAliveTime(keepAliveTime, TimeUnit.MILLISECONDS);
executor.setRemoveOnCancelPolicy(true);
executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
return executor;
}
@Override
public void validate() {
// Do nothing
}
};
this.builder.threadPoolFactory(factory);
return this;
}
use of org.wildfly.clustering.service.concurrent.ClassLoaderThreadFactory in project wildfly by wildfly.
the class ThreadPoolBuilder method configure.
@Override
public Builder<ThreadPoolConfiguration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
ThreadPoolExecutorFactory<?> factory = new BlockingThreadPoolExecutorFactory(this.definition.getMaxThreads().resolveModelAttribute(context, model).asInt(), this.definition.getMinThreads().resolveModelAttribute(context, model).asInt(), this.definition.getQueueLength().resolveModelAttribute(context, model).asInt(), this.definition.getKeepAliveTime().resolveModelAttribute(context, model).asLong()) {
@Override
public ExecutorService createExecutor(ThreadFactory factory) {
return super.createExecutor(new ClassLoaderThreadFactory(factory, ClassLoaderThreadFactory.class.getClassLoader()));
}
};
this.builder.threadPoolFactory(factory);
return this;
}
Aggregations