Skip to content

Commit 369b88f

Browse files
author
tiansh
committed
update:优化线程池
1 parent bfa41ac commit 369b88f

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@
3939
[Core版](https://hellohao.cn):开源版的基础上增加`Backblaze(B2)` 并且可`同个对象存储商家`可开多个存储源(可添加至90+存储源)
4040

4141

42-
### 更新日志 `20240111`
42+
### 更新日志 `20240124`
4343

44+
- 新增支持对接WebDAV存储源
4445
- 修复本地存储源上传失败的情况
4546
- 修复某些存储源目录创建不正确的问题
4647
- 优化页面部分提示
48+
- 修复潜在的一些安全隐患
49+
4750

4851

4952
### 主要功能
@@ -151,6 +154,8 @@
151154

152155
更多部署教程参考程序[相关文档](http://doc.hellohao.cn)
153156

157+
更强大的功能可[购买Core版](http://tbed.hellohao.cn/pay)程序
158+
154159

155160
### 启动项目
156161
> 访问你的前端域名即可
@@ -186,7 +191,7 @@
186191

187192
![Hellohao图像托管](https://hellohao.cn/newassets/img/twechat.png)
188193

189-
[//]: # (![Hellohao图像托管](https://upload.cc/i1/2022/03/28/Vnp0bT.png))
194+
[//]: # "![Hellohao图像托管](https://upload.cc/i1/2022/03/28/Vnp0bT.png)"
190195

191196

192197
### 运行环境
@@ -233,4 +238,3 @@ Hellohao图像托管已申请[**中国国家版权局计算机软件著作权**]
233238
**如需程序定制或其他业务,请与我们取得联系**
234239
[Hellohao图像托管官网](http://hellohao.cn)
235240

236-

src/main/java/cn/hellohao/config/PoolConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public class PoolConfig {
1616
@Bean(name = "taskExecutor")
1717
public ThreadPoolTaskExecutor taskExecutor() {
1818
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
19-
executor.setCorePoolSize(properties.getCorePoolSize());
20-
executor.setMaxPoolSize(properties.getMaxPoolSize());
21-
executor.setQueueCapacity(properties.getQueueCapacity());
19+
executor.setCorePoolSize(properties.getCorePoolSize()); //设置核心线程数
20+
executor.setMaxPoolSize(properties.getMaxPoolSize()); //设置最大线程数
21+
executor.setQueueCapacity(properties.getQueueCapacity()); //设置队列容量
2222
executor.setThreadNamePrefix(properties.getThreadNamePrefix());
2323
executor.setKeepAliveSeconds(properties.getKeepAliveTime());
2424
executor.setWaitForTasksToCompleteOnShutdown(properties.isWaitForTasksToCompleteOnShutdown());
@@ -42,7 +42,7 @@ class ThreadPoolProperties {
4242
private int corePoolSize = 5;
4343
private int maxPoolSize = 50;
4444
private int keepAliveTime = 15;
45-
private int queueCapacity = 6;
45+
private int queueCapacity = 10;
4646
private String threadNamePrefix = "Tbed-Thread";
4747
private boolean allowCoreThreadTimeout = false;
4848
private boolean waitForTasksToCompleteOnShutdown = false;

src/main/java/cn/hellohao/service/impl/ClientService.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import org.slf4j.Logger;
1212
import org.slf4j.LoggerFactory;
1313
import org.springframework.beans.factory.annotation.Autowired;
14+
import org.springframework.scheduling.annotation.Async;
15+
import org.springframework.scheduling.annotation.EnableAsync;
1416
import org.springframework.stereotype.Service;
1517
import org.springframework.web.multipart.MultipartFile;
1618

@@ -26,12 +28,11 @@
2628
* @date 2021/10/28 16:38
2729
*/
2830
@Service
31+
@EnableAsync
2932
public class ClientService {
3033
private static Logger logger = LoggerFactory.getLogger(ClientService.class);
31-
@Autowired
32-
ConfdataService confdataService;
33-
@Autowired
34-
SysConfigService sysConfigService;
34+
@Autowired private ConfdataService confdataService;
35+
@Autowired private SysConfigService sysConfigService;
3536
@Autowired private UserMapper userMapper;
3637
@Autowired private KeysMapper keysMapper;
3738
@Autowired private UploadConfigMapper uploadConfigMapper;
@@ -40,6 +41,7 @@ public class ClientService {
4041
@Autowired private GetSource getSource;
4142
@Autowired private ImgViolationJudgeServiceImpl imgViolationJudgeService;
4243

44+
@Async("taskExecutor")
4345
public Msg uploadImg(
4446
HttpServletRequest request, MultipartFile multipartFile, String email, String pass,Integer setday) {
4547
Msg msg = new Msg();

src/main/java/cn/hellohao/service/impl/UploadServicel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import org.slf4j.Logger;
1919
import org.slf4j.LoggerFactory;
2020
import org.springframework.beans.factory.annotation.Autowired;
21+
import org.springframework.scheduling.annotation.Async;
22+
import org.springframework.scheduling.annotation.EnableAsync;
2123
import org.springframework.stereotype.Service;
2224

2325
import javax.servlet.http.HttpServletRequest;
@@ -33,6 +35,7 @@
3335
* @date 2020/1/9 15:46
3436
*/
3537
@Service
38+
@EnableAsync
3639
public class UploadServicel {
3740
private static Logger logger = LoggerFactory.getLogger(UploadServicel.class);
3841
@Autowired
@@ -48,6 +51,7 @@ public class UploadServicel {
4851
@Autowired deleImages deleimages;
4952
@Autowired ImgViolationJudgeServiceImpl imgViolationJudgeService;
5053

54+
@Async("taskExecutor")
5155
public Msg uploadForLoc(
5256
HttpServletRequest request,
5357
File file,

0 commit comments

Comments
 (0)