测试线程池
parent
7ab95fa65d
commit
925806c247
|
@ -8,6 +8,7 @@ import com.muyu.domain.*;
|
||||||
import com.muyu.domain.req.TaskInfoReq;
|
import com.muyu.domain.req.TaskInfoReq;
|
||||||
import com.muyu.mapper.TaskMapper;
|
import com.muyu.mapper.TaskMapper;
|
||||||
import com.muyu.service.*;
|
import com.muyu.service.*;
|
||||||
|
import com.muyu.task.PriorityThreadPool;
|
||||||
import com.muyu.task.feign.DataValueClient;
|
import com.muyu.task.feign.DataValueClient;
|
||||||
import com.muyu.task.feign.RuleFeign;
|
import com.muyu.task.feign.RuleFeign;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
@ -197,8 +198,16 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, TaskInfo> implement
|
||||||
log.info("执行查询语句为{}", limitSelect);
|
log.info("执行查询语句为{}", limitSelect);
|
||||||
if(taskInfo.getWeigh() == 4){
|
if(taskInfo.getWeigh() == 4){
|
||||||
log.info("执行紧急任务");
|
log.info("执行紧急任务");
|
||||||
|
PriorityThreadPool.activeEmergencyTasks.set(0);
|
||||||
|
PriorityThreadPool.remainingTasks.set(0);
|
||||||
executeUrgently(() -> {
|
executeUrgently(() -> {
|
||||||
|
try {
|
||||||
selectAndAdd(finalDatabaseId, basicId, limitSelect, tableId,newAndOldMap, finalFirstArray,two);
|
selectAndAdd(finalDatabaseId, basicId, limitSelect, tableId,newAndOldMap, finalFirstArray,two);
|
||||||
|
} finally {
|
||||||
|
if (PriorityThreadPool.remainingTasks.decrementAndGet() == 0) {
|
||||||
|
System.out.println("All emergency tasks have completed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ public class PriorityThreadPool {
|
||||||
// 创建固定大小的线程池
|
// 创建固定大小的线程池
|
||||||
executor = new ThreadPoolExecutor(
|
executor = new ThreadPoolExecutor(
|
||||||
totalThreads, totalThreads,
|
totalThreads, totalThreads,
|
||||||
80L, TimeUnit.SECONDS,
|
40L, TimeUnit.SECONDS,
|
||||||
new LinkedBlockingQueue<Runnable>()
|
new LinkedBlockingQueue<Runnable>()
|
||||||
);
|
);
|
||||||
highPrioritySemaphore = new Semaphore(defaultHighThreads);
|
highPrioritySemaphore = new Semaphore(defaultHighThreads);
|
||||||
|
|
|
@ -22,12 +22,12 @@ spring:
|
||||||
active: dev
|
active: dev
|
||||||
|
|
||||||
cloud:
|
cloud:
|
||||||
openfeign:
|
# openfeign:
|
||||||
client:
|
# client:
|
||||||
config:
|
# config:
|
||||||
default:
|
# default:
|
||||||
connectTimeout: 5000
|
# connectTimeout: 5000
|
||||||
readTimeout: 5000
|
# readTimeout: 5000
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
|
|
Loading…
Reference in New Issue