CallableTaskletAdapter是否使用与步骤本身不同的线程?
@Bean
public Callable<RepeatStatus> callableObject() {
return () -> {
System.out.println(Thread.currentThread().getName());
System.out.println("This was executed in another thread");
return RepeatStatus.FINISHED;
};
}
@Bean
public CallableTaskletAdapter tasklet() {
CallableTaskletAdapter callableTaskletAdapter =new CallableTaskletAdapter();
callableTaskletAdapter.setCallable(callableObject());
return callableTaskletAdapter;
}
@Bean
public Step callableStep() {
System.out.println(Thread.currentThread().getName());
return this.stepBuilderFactory.get("callableStep")
.tasklet(tasklet())
.build();
}
运行此代码在可调用的tasklet中将线程名称打印为“ main”。这意味着它没有使用新线程。我想念什么吗?
CallableTaskletAdapter是否使用与步骤本身不同的线程?