您的位置:首页 > 新闻 > 资讯 > 设计企业品牌商标_厦门建设局电话多少_app开发多少钱_河源市seo点击排名软件价格

设计企业品牌商标_厦门建设局电话多少_app开发多少钱_河源市seo点击排名软件价格

2025/1/7 8:27:06 来源:https://blog.csdn.net/qq_42547733/article/details/144853014  浏览:    关键词:设计企业品牌商标_厦门建设局电话多少_app开发多少钱_河源市seo点击排名软件价格
设计企业品牌商标_厦门建设局电话多少_app开发多少钱_河源市seo点击排名软件价格

yaml文件

fsg:
batch-approval:# 批量审批batch-approval:pool:core-size: 2max-size: 10queue-capacity: 100keep-alive: 60name-prefix: ApprovalThread-shutdown:await-termination: trueawait-termination-period: 60

ConfigurationProperties配置


import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;import java.time.Duration;@Data
@ConfigurationProperties("fsg.batch-approval")
public class BatchApprovalProperties {private Pool pool = new Pool();private Shutdown shutdown = new Shutdown();@Datapublic static class Pool {/*** Queue capacity. An unbounded capacity does not increase the pool and therefore* ignores the "max-size" property.*/private int queueCapacity = 200;/*** Core number of threads.*/private int coreSize = 2;/*** Maximum allowed number of threads. If tasks are filling up the queue, the pool* can expand up to that size to accommodate the load. Ignored if the queue is* unbounded.*/private int maxSize = 10;/*** Whether core threads are allowed to time out. This enables dynamic growing and* shrinking of the pool.*/private boolean allowCoreThreadTimeout = true;/*** Time limit for which threads may remain idle before being terminated.*/private Integer keepAlive = 60;private String namePrefix = "ApprovalThread-";}@Datapublic static class Shutdown {/*** Whether the executor should wait for scheduled tasks to complete on shutdown.*/private boolean awaitTermination;/*** Maximum time the executor should wait for remaining tasks to complete.*/private Duration awaitTerminationPeriod;}}

使用配置文件的属性


import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;import java.util.concurrent.Executor;
@EnableAsync
@Configuration
@EnableConfigurationProperties(BatchApprovalProperties.class)
public class BatchApprovalAsyncConfig {@Bean(name = "batchApprovalTaskExecutor")public Executor batchApprovalTaskExecutor(BatchApprovalProperties props) {ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();executor.setCorePoolSize(props.getPool().getCoreSize()); // 核心线程数executor.setMaxPoolSize(props.getPool().getMaxSize()); // 最大线程数executor.setQueueCapacity(props.getPool().getQueueCapacity()); // 队列大小executor.setKeepAliveSeconds(props.getPool().getKeepAlive()); // 线程空闲时的存活时间executor.setThreadNamePrefix(props.getPool().getNamePrefix()); // 线程名称前缀executor.initialize(); // 初始化线程池return executor;}}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com