当前位置:网站首页>Use the thread factory to set the thread name in the thread pool
Use the thread factory to set the thread name in the thread pool
2022-04-23 03:32:00 【I can fix software】
1、 Implement thread factory interface
public class SmsThreadFactory implements ThreadFactory {
// Thread name
private String sendcode;
public SmsThreadFactory(String sendcode) {
this.sendcode=sendcode;
}
@Override
public Thread newThread(Runnable r) {
// TODO Auto-generated method stub
return new Thread(r, this.sendcode );
}
}
2、 Thread pool creation
// Maximum permission 64 Threads Will be enough ~~ Create thread
ThreadPoolExecutor executor=new ThreadPoolExecutor(8, 32, 30, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(32));
3、 Add threads to the thread pool
// Create thread
Thread sms=new Thread(new SmsThread(msgconf));
SmsThreadFactory smsThreadFactory=new SmsThreadFactory("SENCE_CODE="+msgconf.getSendCode());
// Thread factory Set the name
executor.setThreadFactory(smsThreadFactory);
executor.execute(sms);
版权声明
本文为[I can fix software]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220607291176.html
边栏推荐
- Learn about I / O flow and file operations
- Supersocket is Used in net5 - command
- 2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
- Quartz. Www. 18fu Used in net core
- 浅学一下I/O流和File类文件操作
- Query stored procedures in PostgreSQL
- Initial experience of talent plan learning camp: communication + adhering to the only way to learn open source collaborative courses
- Generate QR code through zxing
- Unity Basics
- Detailed explanation of socket programming send() and recv() functions
猜你喜欢

Section 1 array and slicing in Chapter 6

移植tslib时ts_setup: No such file or directory、ts_open: No such file or director

Design and implementation of redis (3): persistence strategy RDB, AOF

深度学习笔记(二)——激活函数原理与实现

2022 团体程序设计天梯赛 模拟赛 L2-4 哲哲打游戏 (25 分)

【微服务】(十)—— 统一网关Gateway

Code forces round # 784 (DIV. 4) solution (First AK CF (XD)

Deep learning notes (II) -- principle and implementation of activation function

JS inheritance

Test questions (2)
随机推荐
Learn about I / O flow and file operations
Supersocket is Used in net5 - command
Using swagger in. Net5
2021-08-31
MySQL grouping query rules
Chapter VI, Section III pointer
Codeforces round 784 (Div. 4) (AK CF (XD) for the first time)
Codeforces Round #784 (Div. 4)题解 (第一次AK cf (XD
. net 5 Web custom middleware implementation returns the default picture
If statement format flow
PWA I'm here
7-2 Tushare
Design and implementation of redis (1): understand data structures and objects
Scenario Title: how does system a use the page of system B
月薪10k-20k都无法回答的事务问题,你会吗?
Basic use of Charles
【微服务】(十)—— 统一网关Gateway
Super easy to use [general excel import function]
you need to be root to perform this command
Unity Basics