use of org.jgroups.util.ShutdownRejectedExecutionHandler in project wildfly by wildfly.
the class ThreadPoolFactoryBuilder method build.
@Override
public ServiceBuilder<ThreadPoolFactory> build(ServiceTarget target) {
int queueLength = this.getQueueLength();
BlockingQueue<Runnable> queue = (queueLength > 0) ? new ArrayBlockingQueue<>(queueLength) : new SynchronousQueue<>();
ClassLoader loader = JChannelFactory.class.getClassLoader();
ThreadFactory threadFactory = new ClassLoaderThreadFactory(new DefaultThreadFactory(this.getThreadGroupPrefix(), false, true), loader);
RejectedExecutionHandler handler = new ShutdownRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
ThreadPoolFactory factory = () -> new ThreadPoolExecutor(this.getMinThreads(), this.getMaxThreads(), this.getKeepAliveTime(), TimeUnit.MILLISECONDS, queue, threadFactory, handler);
return target.addService(this.getServiceName(), new ValueService<>(new ImmediateValue<>(factory)));
}
Aggregations