ThreadPoolExecutor线程池如何自定义拒绝策略
解决方法:
1.第一种写法:
pool.setRejectedExecutionHandler((r, executor) -> {
//业务代码
});
2.第二种写法:
public class YourRejectPolicy implements RejectedExecutionHandler{
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
//业务代码
}
}
向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti