Spring、Java - 运行 多个并行计划任务

Spring, Java - run many scheduled-tasks in parallel

我尝试 运行 许多与调度程序并行的计划任务,但只有一个启动。 我的 beans 配置在 spring-scheduler.xml

<?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:p="http://www.springframework.org/schema/p"
    xmlns:task="http://www.springframework.org/schema/task"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
            http://www.springframework.org/schema/task
            http://www.springframework.org/schema/task/spring-task-3.2.xsd">

    <task:executor id="executor" pool-size="5"/>
    <task:scheduler id="scheduler" pool-size="10"/>

    <bean id="UpdateScheduler" class="org.ws.scheduled.UpdateScheduler" />
    <bean id="PatchData" class="org.ws.scheduled.PatchData" />

    <task:scheduled-tasks> 
        <task:scheduled ref="UpdateScheduler" method="start" fixed-delay="1000" />
        <task:scheduled ref="PatchData" method="start" fixed-delay="5000" />
    </task:scheduled-tasks>

    <task:annotation-driven scheduler="scheduler" executor="executor" />

</beans>

谢谢大家! 我开始使用这个配置,它从这里开始工作正常 https://docs.spring.io/spring/docs/current/spring-framework-reference/integration.html#scheduling-task-namespace-scheduled-tasks

<task:scheduled-tasks scheduler="myScheduler">
    <task:scheduled ref="beanA" method="methodA" fixed-delay="5000" initial-delay="1000"/>
    <task:scheduled ref="beanB" method="methodB" fixed-rate="5000"/>
    <task:scheduled ref="beanC" method="methodC" cron="*/5 * * * * MON-FRI"/>