当前位置:网站首页>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
边栏推荐
- Code forces round # 784 (DIV. 4) solution (First AK CF (XD)
- POI create and export Excel based on data
- There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
- Supersocket is Use in net5 - concept
- QT uses drag and drop picture to control and mouse to move picture
- Test questions and some space wars
- JS, bind the event for a label with input, and then bind the stand-alone event in the parent element. The event is executed twice and solved
- MySQL query specifies that a row is sorted to the first row
- Alphafpld upgrade alphafold multimer
- The fourth operation
猜你喜欢

全新的ORM框架——BeetlSQL介绍

Codeforces round 784 (Div. 4) (AK CF (XD) for the first time)

2022 group programming ladder game simulation L2-4 Zhezhi game (25 points)

Redis(17) -- Redis缓存相关问题解决
![Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]](/img/1a/a22b4a35d3c083438d0f766a5ecb08.png)
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]

The art of concurrent programming (2): synchronized usage scenarios

IDEA查看历史记录【文件历史和项目历史】

Test questions (2)

MySQL query specifies that a row is sorted to the first row

JS - accuracy issues
随机推荐
JS takes out the same elements in two arrays
The query type of MySQL is very inefficient.
Romantic silhouette of L2-3 of 2022 group programming ladder Simulation Competition (25 points)
Codeforces Round #784 (Div. 4)題解 (第一次AK cf (XD
QT dynamic translation of Chinese and English languages
Do you really understand hashcode and equals???
A hundred dollars for a hundred chickens
Section 2 map and structure in Chapter 6
PYMOL-note
MySQL grouping query rules
Scenario Title: how does system a use the page of system B
Batch download of files ---- compressed and then downloaded
Unity knowledge points (ugui 2)
Basic use of Charles
2022 团体程序设计天梯赛 模拟赛 1-8 均是素数 (20 分)
There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
2022 团体程序设计天梯赛 模拟赛 L2-3 浪漫侧影 (25 分)
Database SQL -- simulate inserting a large amount of data, importing / exporting database scripts, timestamp conversion and database basics
POI create and export Excel based on data
socket編程 send()與 recv()函數詳解