Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
PubTools-tools
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuxingyu
PubTools-tools
Commits
a80d9858
Commit
a80d9858
authored
Aug 10, 2023
by
lihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交README文件
parent
978a2515
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
README.md
task-executor-kit/README.md
+37
-0
No files found.
task-executor-kit/README.md
0 → 100644
View file @
a80d9858
# 项目介绍
多线程处理列表逻辑
# 使用方式
1.
获取任务执行实例
```java
TaskExecutor<User, User, String> executor = TaskPoolFactory.createExecutor();
```
2.
初始化执行器
```java
executor.init(
(data, context) -> {
data.setName(data.getName() + "handle");
try {
Thread.sleep(SLEEP_TIME);
} catch (InterruptedException e) {
e.printStackTrace();
}
return "success";
}, // 需要处理的业务逻辑
list, // 需要处理的业务数据列表
new User(30, "leehyoo") // 其他公用查询参数
);
```
3.
获取查询结果
```java
boolean result = executor.execute();
```
# 注意事项
1.
没有事务处理
2.
尽量避免在循环中查询数据库
3.
context内容建议不要修改,只作为逻辑判断、查询等使用
4.
尽量使用自定义的线程池
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment