以下代码如何工作? flow1和flow2是否会同时启动?第4步何时开始?
let bulletSVG = document.createElement("object");
bulletSVG.setAttribute("class", "bullet");
bulletSVG.setAttribute("type", "image/svg+xml");
bulletSVG.setAttribute("data", "imgs/bullet.svg");
document.body.appendChild(bulletSVG);
console.log(bulletSVG.getBoundingClientRect());
}
答案 0 :(得分:0)
是的,流程1和流程2在您提供的代码中同时启动。在Split方法中,您传递了一个异步任务执行器的实现,该实现可确保流并行运行,通过自定义实现并分配线程组名称,您可以在日志中自己查看它。
@Bean
public TaskExecutor taskExecutor() {
ThreadGroup threadGroup = new ThreadGroup("Example");
Runtime runtime = Runtime.getRuntime();
int nrCpu = runtime.availableProcessors();
SimpleAsyncTaskExecutor asyncTaskExecutor = new
SimpleAsyncTaskExecutor("split-flow");
asyncTaskExecutor.setThreadGroup(threadGroup);
asyncTaskExecutor.setConcurrencyLimit(10);
return asyncTaskExecutor;
}
在日志中,您会发现以下内容:
debug 10888 --- [ split-flow1] o.s.batch.core.job.SimpleStepHandler : Executing step: [step1]
debug 10888 --- [ split-flow2] o.s.batch.core.job.SimpleStepHandler : Executing step: [step3]
这里,split-flow1和split-flow2是两个不同的线程。