spring the task default is single-threaded execution, if too many regular tasks, a task execution time is too long, it may affect the frequency of execution of other tasks, therefore, it is necessary to add multi-threaded parallel execution, can effectively reduce the task is chance of impact. The solution is to modify the configuration xml file, as follows:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd"
default-autowire="byName" default-lazy-init="false">
<!-- 1.扫描指定的包 -->
<context:component-scan base-package="com.qfx.system.task"/>
<!-- 2.启用定时任务 -->
<!-- <task:annotation-driven /> -->
<task:annotation-driven scheduler="myTask" />
<!-- 3.配置定时任务的线程池 -->
<task:scheduler id="myTask" pool-size="5"/>
</beans>