当前位置:网站首页>使用TransmittableThreadLocal实现参数跨线程传递
使用TransmittableThreadLocal实现参数跨线程传递
2022-04-23 05:45:00 【dawnsun001】
- 创建ThreadLocalContext
public class ThreadLocalContext {
public static TransmittableThreadLocal<SystemParams> systemParamsThreadLocal = new TransmittableThreadLocal<>();
}
- 赋值
ThreadLocalContext.systemParamsThreadLocal.set(systemParamsDTO);
- 线程池配置
@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://blog.csdn.net/dawnsun2013/article/details/124330192
边栏推荐
- Option的正确打开方式
- [untitled] database - limit the number of returned rows
- 8. Integer Decomposition
- Kalman filter and inertial integrated navigation
- How SYSTEMd uses / etc / init D script
- Robocode教程5——Enemy类
- xlsxwriter.exceptions.FileCreateError: [Errno 13] Permission denied问题
- Collection and map thread safety problem solving
- [leetcode 202] happy number
- 用二进制进行权限管理
猜你喜欢
随机推荐
6.Reversal
P1018 maximum product solution
Advanced operation of idea debug
Storing inherited knowledge in cloud computing
爬取彩票数据
Import of data
破解滑动验证码
[leetcode 290] word rules
MySQL groups are sorted by a field, and the first value is taken
Rust 中的 RefCell
10.Advance Next Round
Type conversion in C #
7-21日错题涉及知识点。
Database - sorting data
Integration and induction of knowledge points of automatic control principle (Han min version)
SQL sorts according to the specified content
Detection technology and principle
Animation - Introduction to keyframes
P1586 solution to tetragonal theorem
MySQL table constraints and table design









