当前位置:网站首页>使用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
边栏推荐
猜你喜欢

Addition, deletion, query and modification of data

Robocode教程7——雷达锁定

Rust的闭包类型(Fn, FnMut, FnOne的区别)

SQL sorts according to the specified content

Explanation of the second I interval of 2020 Niuke summer multi school training camp

-- SQL query and return limit rows

SQL -- data filtering and grouping

Mysql database foundation

P1586 solution to tetragonal theorem

Robocode教程4——Robocode的游戏物理
随机推荐
根据SQL语句查询出的结果集,将其封装为json
Export of data
斯坦福机器学习课程汇总
6.Reversal
Rust 中的 RefCell
C language file operation
8. Integer Decomposition
Basemap库绘制地图
Database - sorting data
基于pygame库编写的五子棋游戏
Rust的闭包类型(Fn, FnMut, FnOne的区别)
Installation and usage skills of idea
程序設計訓練
selenium+PhantomJS破解滑动验证2
[leetcode169] most elements
11.a==b?
用二进制进行权限管理
Explanation of login page
POI and easyexcel exercises
Usage scenario of copyonwritearraylist