当前位置:网站首页>使用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
边栏推荐
- 6.Reversal
- 爬取彩票数据
- [leetcode217] there are duplicate elements
- MySQL occasional Caton
- Techniques et principes de détection
- MySQL groups are sorted by a field, and the first value is taken
- Feign请求日志统一打印
- SQL sorts according to the specified content
- 根据SQL语句查询出的结果集,将其封装为json
- Record the installation and configuration of gestermer on TX2, and then use GST RTSP server
猜你喜欢
MySQL groups are sorted by a field, and the first value is taken
Robocode教程5——Enemy类
How SYSTEMd uses / etc / init D script
C language file operation
[leetcode 19] delete the penultimate node of the linked list
MySQL advanced query
The most practical chrome plug-in
Kalman filter and inertial integrated navigation
Explanation of login page
GDAL+OGR学习
随机推荐
Cf6d lizards and fundamentals 2 problem solving
Excel打开超大csv格式数据
serde - rust的序列化方案
Busybox initrd and initialization process
Integers have friends interval GCD + double pointer
Mysql database foundation
MySQL table constraints and table design
Customized communication between threads (reentrantlock)
Rust 中的指针:Box、Rc、Cell、RefCell
Rust 的 Box指针
根据SQL语句查询出的结果集,将其封装为json
Introduction to virtualization features
How SYSTEMd uses / etc / init D script
Addition, deletion, modification and query of MySQL table
Rust 的多线程安全引用 Arc
Rust:如何实现一个线程池?
Rust 中的 Rc智能指针
Type conversion in C #
[leetcode 54] spiral matrix
Collections multiple parameter sorting