Java 停止spring批处理中运行的线程
我有一个Spring批处理应用程序,它使用分区来运行一些线程。 问题是,如果线程到达某个时间,我需要停止线程 我不知道怎么做。 我有一个分裂步骤Java 停止spring批处理中运行的线程,java,spring,multithreading,spring-batch,java-threads,Java,Spring,Multithreading,Spring Batch,Java Threads,我有一个Spring批处理应用程序,它使用分区来运行一些线程。 问题是,如果线程到达某个时间,我需要停止线程 我不知道怎么做。 我有一个分裂步骤 @Bean public Step partitionerStep() { return stepBuilderFactory.get("PARTITIONER_STEP") .partitioner("SLAVE_STEP", partitioner()) .step(stepConcederP
@Bean
public Step partitionerStep() {
return stepBuilderFactory.get("PARTITIONER_STEP")
.partitioner("SLAVE_STEP", partitioner())
.step(stepConcederPerfilNormal())
.taskExecutor(taskExecutor())
.build();
}
首先,我想我可以使用ThreadPoolTaskExecutor停止我的线程,但它并不像我想的那样工作
@Bean
public TaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setMaxPoolSize(200);
executor.setCorePoolSize(50);
executor.setAllowCoreThreadTimeOut(true);
return executor;
}
只是为了修复它。我需要停止我的线程,如果它运行1H30MSpring Batch没有创建或管理线程,它会将其委托给
任务执行器
我需要停止我的线程,如果它运行1H30M
以下内容可能会有所帮助: