
com.github.joekerouac.common.tools.thread.ThreadPoolConfig Maven / Gradle / Ivy
The newest version!
// Generated by delombok at Fri Mar 14 11:41:38 CST 2025
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
* file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
* to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.github.joekerouac.common.tools.thread;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* 线程池配置
*
* @since 1.0.0
* @author JoeKerouac
* @date 2022-10-14 14:37:00
*/
public class ThreadPoolConfig {
/**
* 核心线程池大小
*/
@Min(1)
private int corePoolSize = 10;
/**
* 最大线程池大小
*/
@Min(1)
private int maximumPoolSize = 10;
/**
* 线程存活时间,如果当前线程池大小超过核心大小,那么超过该存活时间的线程将被清理
*/
@Min(1)
private long keepAliveTime = 300;
/**
* 时间单位
*/
@NotNull
private TimeUnit timeUnit = TimeUnit.SECONDS;
/**
* 工作队列,允许为空,为空时使用{@link #queueSize}来构建队列
*/
private BlockingQueue workQueue;
/**
* 如果{@link #workQueue}为null,将会使用该字段构建队列;
*/
@Min(1)
private int queueSize = 100;
/**
* 线程池工厂,允许为空
*/
private ThreadFactory threadFactory;
/**
* 拒绝策略,允许为空
*/
private RejectedExecutionHandler rejectedExecutionHandler;
/**
* 异常处理,允许为空,为空时使用默认处理器,只打印日志
*/
private Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
/**
* 默认线程上下文类加载器,{@link #threadFactory}为空时有用;
*/
private ClassLoader defaultContextClassLoader;
@java.lang.SuppressWarnings("all")
@lombok.Generated
public ThreadPoolConfig() {
}
/**
* 核心线程池大小
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public int getCorePoolSize() {
return this.corePoolSize;
}
/**
* 最大线程池大小
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public int getMaximumPoolSize() {
return this.maximumPoolSize;
}
/**
* 线程存活时间,如果当前线程池大小超过核心大小,那么超过该存活时间的线程将被清理
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public long getKeepAliveTime() {
return this.keepAliveTime;
}
/**
* 时间单位
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public TimeUnit getTimeUnit() {
return this.timeUnit;
}
/**
* 工作队列,允许为空,为空时使用{@link #queueSize}来构建队列
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public BlockingQueue getWorkQueue() {
return this.workQueue;
}
/**
* 如果{@link #workQueue}为null,将会使用该字段构建队列;
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public int getQueueSize() {
return this.queueSize;
}
/**
* 线程池工厂,允许为空
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public ThreadFactory getThreadFactory() {
return this.threadFactory;
}
/**
* 拒绝策略,允许为空
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public RejectedExecutionHandler getRejectedExecutionHandler() {
return this.rejectedExecutionHandler;
}
/**
* 异常处理,允许为空,为空时使用默认处理器,只打印日志
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public Thread.UncaughtExceptionHandler getUncaughtExceptionHandler() {
return this.uncaughtExceptionHandler;
}
/**
* 默认线程上下文类加载器,{@link #threadFactory}为空时有用;
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public ClassLoader getDefaultContextClassLoader() {
return this.defaultContextClassLoader;
}
/**
* 核心线程池大小
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public void setCorePoolSize(final int corePoolSize) {
this.corePoolSize = corePoolSize;
}
/**
* 最大线程池大小
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public void setMaximumPoolSize(final int maximumPoolSize) {
this.maximumPoolSize = maximumPoolSize;
}
/**
* 线程存活时间,如果当前线程池大小超过核心大小,那么超过该存活时间的线程将被清理
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public void setKeepAliveTime(final long keepAliveTime) {
this.keepAliveTime = keepAliveTime;
}
/**
* 时间单位
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public void setTimeUnit(final TimeUnit timeUnit) {
this.timeUnit = timeUnit;
}
/**
* 工作队列,允许为空,为空时使用{@link #queueSize}来构建队列
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public void setWorkQueue(final BlockingQueue workQueue) {
this.workQueue = workQueue;
}
/**
* 如果{@link #workQueue}为null,将会使用该字段构建队列;
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public void setQueueSize(final int queueSize) {
this.queueSize = queueSize;
}
/**
* 线程池工厂,允许为空
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public void setThreadFactory(final ThreadFactory threadFactory) {
this.threadFactory = threadFactory;
}
/**
* 拒绝策略,允许为空
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public void setRejectedExecutionHandler(final RejectedExecutionHandler rejectedExecutionHandler) {
this.rejectedExecutionHandler = rejectedExecutionHandler;
}
/**
* 异常处理,允许为空,为空时使用默认处理器,只打印日志
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public void setUncaughtExceptionHandler(final Thread.UncaughtExceptionHandler uncaughtExceptionHandler) {
this.uncaughtExceptionHandler = uncaughtExceptionHandler;
}
/**
* 默认线程上下文类加载器,{@link #threadFactory}为空时有用;
*/
@java.lang.SuppressWarnings("all")
@lombok.Generated
public void setDefaultContextClassLoader(final ClassLoader defaultContextClassLoader) {
this.defaultContextClassLoader = defaultContextClassLoader;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@lombok.Generated
public boolean equals(final java.lang.Object o) {
if (o == this) return true;
if (!(o instanceof ThreadPoolConfig)) return false;
final ThreadPoolConfig other = (ThreadPoolConfig) o;
if (!other.canEqual((java.lang.Object) this)) return false;
if (this.getCorePoolSize() != other.getCorePoolSize()) return false;
if (this.getMaximumPoolSize() != other.getMaximumPoolSize()) return false;
if (this.getKeepAliveTime() != other.getKeepAliveTime()) return false;
if (this.getQueueSize() != other.getQueueSize()) return false;
final java.lang.Object this$timeUnit = this.getTimeUnit();
final java.lang.Object other$timeUnit = other.getTimeUnit();
if (this$timeUnit == null ? other$timeUnit != null : !this$timeUnit.equals(other$timeUnit)) return false;
final java.lang.Object this$workQueue = this.getWorkQueue();
final java.lang.Object other$workQueue = other.getWorkQueue();
if (this$workQueue == null ? other$workQueue != null : !this$workQueue.equals(other$workQueue)) return false;
final java.lang.Object this$threadFactory = this.getThreadFactory();
final java.lang.Object other$threadFactory = other.getThreadFactory();
if (this$threadFactory == null ? other$threadFactory != null : !this$threadFactory.equals(other$threadFactory)) return false;
final java.lang.Object this$rejectedExecutionHandler = this.getRejectedExecutionHandler();
final java.lang.Object other$rejectedExecutionHandler = other.getRejectedExecutionHandler();
if (this$rejectedExecutionHandler == null ? other$rejectedExecutionHandler != null : !this$rejectedExecutionHandler.equals(other$rejectedExecutionHandler)) return false;
final java.lang.Object this$uncaughtExceptionHandler = this.getUncaughtExceptionHandler();
final java.lang.Object other$uncaughtExceptionHandler = other.getUncaughtExceptionHandler();
if (this$uncaughtExceptionHandler == null ? other$uncaughtExceptionHandler != null : !this$uncaughtExceptionHandler.equals(other$uncaughtExceptionHandler)) return false;
final java.lang.Object this$defaultContextClassLoader = this.getDefaultContextClassLoader();
final java.lang.Object other$defaultContextClassLoader = other.getDefaultContextClassLoader();
if (this$defaultContextClassLoader == null ? other$defaultContextClassLoader != null : !this$defaultContextClassLoader.equals(other$defaultContextClassLoader)) return false;
return true;
}
@java.lang.SuppressWarnings("all")
@lombok.Generated
protected boolean canEqual(final java.lang.Object other) {
return other instanceof ThreadPoolConfig;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@lombok.Generated
public int hashCode() {
final int PRIME = 59;
int result = 1;
result = result * PRIME + this.getCorePoolSize();
result = result * PRIME + this.getMaximumPoolSize();
final long $keepAliveTime = this.getKeepAliveTime();
result = result * PRIME + (int) ($keepAliveTime >>> 32 ^ $keepAliveTime);
result = result * PRIME + this.getQueueSize();
final java.lang.Object $timeUnit = this.getTimeUnit();
result = result * PRIME + ($timeUnit == null ? 43 : $timeUnit.hashCode());
final java.lang.Object $workQueue = this.getWorkQueue();
result = result * PRIME + ($workQueue == null ? 43 : $workQueue.hashCode());
final java.lang.Object $threadFactory = this.getThreadFactory();
result = result * PRIME + ($threadFactory == null ? 43 : $threadFactory.hashCode());
final java.lang.Object $rejectedExecutionHandler = this.getRejectedExecutionHandler();
result = result * PRIME + ($rejectedExecutionHandler == null ? 43 : $rejectedExecutionHandler.hashCode());
final java.lang.Object $uncaughtExceptionHandler = this.getUncaughtExceptionHandler();
result = result * PRIME + ($uncaughtExceptionHandler == null ? 43 : $uncaughtExceptionHandler.hashCode());
final java.lang.Object $defaultContextClassLoader = this.getDefaultContextClassLoader();
result = result * PRIME + ($defaultContextClassLoader == null ? 43 : $defaultContextClassLoader.hashCode());
return result;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@lombok.Generated
public java.lang.String toString() {
return "ThreadPoolConfig(corePoolSize=" + this.getCorePoolSize() + ", maximumPoolSize=" + this.getMaximumPoolSize() + ", keepAliveTime=" + this.getKeepAliveTime() + ", timeUnit=" + this.getTimeUnit() + ", workQueue=" + this.getWorkQueue() + ", queueSize=" + this.getQueueSize() + ", threadFactory=" + this.getThreadFactory() + ", rejectedExecutionHandler=" + this.getRejectedExecutionHandler() + ", uncaughtExceptionHandler=" + this.getUncaughtExceptionHandler() + ", defaultContextClassLoader=" + this.getDefaultContextClassLoader() + ")";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy