当前位置:网站首页>Using transmittablethreadlocal to realize parameter cross thread transmission
Using transmittablethreadlocal to realize parameter cross thread transmission
2022-04-23 18:11:00 【dawnsun001】
- establish ThreadLocalContext
public class ThreadLocalContext {
public static TransmittableThreadLocal<SystemParams> systemParamsThreadLocal = new TransmittableThreadLocal<>();
}
- assignment
ThreadLocalContext.systemParamsThreadLocal.set(systemParamsDTO);
- Thread pool configuration
@Configuration
public class ThreadPoolConfig {
@Bean
public ExecutorService threadPoolExecutor(){
return TtlExecutors.getTtlExecutorService(new ThreadPoolExecutor(
10, 1000,30000L, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(2000),
new CustomizableThreadFactory("thread-pool-"),
RejectPolicy.ABORT.getValue()));
}
}
版权声明
本文为[dawnsun001]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230544288977.html
边栏推荐
- Rust: shared variable in thread pool
- Win1远程出现“这可能是由于credssp加密oracle修正”解决办法
- Crawl the product data of Xiaomi Youpin app
- C [file operation] read TXT text by line
- .105Location
- Arcpy adds fields and loop assignments to vector data
- Docker 安装 MySQL
- Stanford machine learning course summary
- I/O多路复用及其相关详解
- Correct opening method of option
猜你喜欢
ArcGIS table to excel exceeds the upper limit, conversion failed
Auto. JS custom dialog box
Deep learning classic network analysis and target detection (I): r-cnn
Implementation of k8s redis one master multi slave dynamic capacity expansion
Transfer learning of five categories of pictures based on VGg
【ACM】70. 爬楼梯
positioner
Calculation of fishing net road density
【ACM】376. 摆动序列
Robocode tutorial 8 - advanced robot
随机推荐
Rust: how to match a string?
Implementation of object detection case based on SSD
ArcGIS license error -15 solution
Win1远程出现“这可能是由于credssp加密oracle修正”解决办法
Romance in C language
Random number generation of C #
Install pyshp Library
Rust: shared variable in thread pool
An example of linear regression based on tensorflow
Auto.js 自定义对话框
消费者灰度实现思路
Implementation of k8s redis one master multi slave dynamic capacity expansion
Process management command
Qt读写XML文件(含源码+注释)
Mode of interprocess communication
【ACM】70. climb stairs
Jenkspy package installation
Logic regression principle and code implementation
According to the result set queried by SQL statement, it is encapsulated as JSON
MATLAB小技巧(6)七种滤波方法比较