先说一下我遇到的问题。业务场景是需要一次性查出多种数据并汇总。这些数据来源有着各自的查询逻辑。如果顺序执行需要花费大量时间。所以想到了用线程池去处理。
先上配置类和配置信息
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @author Administrator
*/
@ConfigurationProperties(prefix = "threadpool.property")
@Component
public class SpringThreadPoolPropertyConfig {
private Integer corePoolSize;
private Integer maxPoolSize;
private Integer keepAliveSeconds;
private Integer queueCapacity;
private Integer awaitTerminationSeconds;
private String threadNamePrefix;
private Boolean waitForTasksToCompleteOnShutdown;
public Integer getCorePoolSize() {
return corePoolSize;
}
public void setCorePoolSize(Integer corePoolSize) {
this.corePoolSize = corePoolSize;
}
public Integer getMaxPoolSize() {
return maxPoolSize;
}
public void setMaxPoolSize(Integer maxPoolSize) {
this.maxPoolSize = maxPoolSize;
}
public Integer getKeepAliveSeconds() {
return keepAliveSeconds;
}
public void setKeepAliveSeconds(Integer keepAliveSeconds) {
this.keepAliveSeconds = keepAliveSeconds;
}
public Integer getQueueCapacity() {
return queueCapacity;
}
public void setQueueCapacity(Integer queueCapacity) {
this.queueCapacity = queueCapacity;
}
public Integer getAwaitTerminationSeconds() {
return awaitTerminationSeconds;